Skip to content

Commit 13db95f

Browse files
committed
Comment set to null issue fix
1 parent 7612743 commit 13db95f

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

src/KVOption.php

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,17 @@ public function get($key, $default = null)
6868
*/
6969
public function set($key, $value, $comment = null)
7070
{
71-
$this->updateOrCreate(
72-
['key' => $key],
73-
['value' => $value, 'comment' => $comment]
74-
);
71+
if ($comment == null) {
72+
$this->updateOrCreate(
73+
['key' => $key],
74+
['value' => $value]
75+
);
76+
} else {
77+
$this->updateOrCreate(
78+
['key' => $key],
79+
['value' => $value, 'comment' => $comment]
80+
);
81+
}
7582
}
7683

7784
/**
@@ -83,7 +90,7 @@ public function set($key, $value, $comment = null)
8390
public function setArray($array)
8491
{
8592
// Multiple elements are present
86-
if (is_array($array[0])){
93+
if (is_array($array[0])) {
8794
foreach ($array as $option) {
8895
// Check if comment is available.
8996
if (count($option) == 2) {
@@ -98,7 +105,7 @@ public function setArray($array)
98105
);
99106
}
100107
}
101-
}else{
108+
} else {
102109
$option = $array;
103110
// Check if comment is available.
104111
if (count($option) == 2) {
@@ -113,7 +120,6 @@ public function setArray($array)
113120
);
114121
}
115122
}
116-
117123
}
118124

119125
/**
@@ -168,5 +174,4 @@ public function remove($key)
168174
{
169175
return (bool) $this->where('key', $key)->delete();
170176
}
171-
172-
}
177+
}

0 commit comments

Comments
 (0)