Skip to content

Commit 84a840f

Browse files
qrazipomirleanu
authored andcommitted
Bugfix: update config with given value for loop, not value of duration. (#3)
1 parent 10b3037 commit 84a840f

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

src/GifCreate.php

+13-7
Original file line numberDiff line numberDiff line change
@@ -109,15 +109,17 @@ private function configure(array $config = [])
109109
* @param int $durations
110110
* @param null $loop
111111
*
112-
* @return \pomirleanu\GifCreate\GifCreate
112+
* @return \Pomirleanu\GifCreate\GifCreate
113113
* @throws \Exception
114114
*/
115115
public function create($frames, $durations = 10, $loop = null)
116116
{
117117
if (count($frames) < 2) {
118118
throw new \Exception(sprintf($this->errors[ 'ERR06' ]));
119119
}
120-
$this->setIfSet($durations, $loop);
120+
121+
// Update loop value if passed in.
122+
$this->mergeConfigIfSet('loop', $loop);
121123

122124
// Check if $frames is a dir; get all files in ascending order if yes (else die):
123125
if (! is_array($frames)) {
@@ -146,15 +148,19 @@ public function create($frames, $durations = 10, $loop = null)
146148
return $this->buildFrameSources($frames, $durations);
147149
}
148150

149-
150-
private function setIfSet($loop)
151+
/**
152+
* If value is non-null value, overwrite or add to internal config.
153+
*
154+
* @param $key
155+
* @param $value
156+
*/
157+
private function mergeConfigIfSet($key, $value)
151158
{
152-
if ($loop !== null) {
153-
$this->config[ 'loop' ] = $loop;
159+
if ($value !== null) {
160+
$this->config[$key] = $value;
154161
}
155162
}
156163

157-
158164
/**
159165
* Building the frame sources for the given images
160166
*

0 commit comments

Comments
 (0)