Code Duplication    Length = 20-20 lines in 2 locations

src/Api/Args/Format/Argument.php 1 location

@@ 211-230 (lines=20) @@
208
     *
209
     * @throws InvalidValueException If the default value is invalid.
210
     */
211
    public function setDefaultValue($defaultValue = null)
212
    {
213
        if ($this->isRequired()) {
214
            throw new InvalidValueException('Required arguments do not accept default values.');
215
        }
216
217
        if ($this->isMultiValued()) {
218
            if (null === $defaultValue) {
219
                $defaultValue = array();
220
            } elseif (!is_array($defaultValue)) {
221
                throw new InvalidValueException(sprintf(
222
                    'The default value of a multi-valued argument must be an '.
223
                    'array. Got: %s',
224
                    is_object($defaultValue) ? get_class($defaultValue) : gettype($defaultValue)
225
                ));
226
            }
227
        }
228
229
        $this->defaultValue = $defaultValue;
230
    }
231
232
    /**
233
     * Returns the default value of the argument.

src/Api/Args/Format/Option.php 1 location

@@ 242-261 (lines=20) @@
239
     *
240
     * @throws InvalidValueException If the default value is invalid.
241
     */
242
    public function setDefaultValue($defaultValue = null)
243
    {
244
        if (!$this->acceptsValue()) {
245
            throw new InvalidValueException('Cannot set a default value when using the flag VALUE_NONE.');
246
        }
247
248
        if ($this->isMultiValued()) {
249
            if (null === $defaultValue) {
250
                $defaultValue = array();
251
            } elseif (!is_array($defaultValue)) {
252
                throw new InvalidValueException(sprintf(
253
                    'The default value of a multi-valued option must be an '.
254
                    'array. Got: %s',
255
                    is_object($defaultValue) ? get_class($defaultValue) : gettype($defaultValue)
256
                ));
257
            }
258
        }
259
260
        $this->defaultValue = $defaultValue;
261
    }
262
263
    /**
264
     * Returns the default value of the option.