Code Duplication    Length = 29-29 lines in 2 locations

src/Observers/AbstractObserver.php 1 location

@@ 452-480 (lines=29) @@
449
     *
450
     * @return mixed|null The, almost formatted, value
451
     */
452
    protected function getValue($name, $default = null, callable $callback = null)
453
    {
454
455
        // initialize the value
456
        $value = null;
457
458
        // query whether or not the header is available
459
        if ($this->hasHeader($name)) {
460
            // load the header value
461
            $headerValue = $this->getHeader($name);
462
            // query wheter or not, the value with the requested key is available
463
            if ((isset($this->row[$headerValue]) && $this->row[$headerValue] != '')) {
464
                $value = $this->row[$headerValue];
465
            }
466
        }
467
468
        // query whether or not, a callback has been passed
469
        if ($value != null && is_callable($callback)) {
470
            $value = call_user_func($callback, $value);
471
        }
472
473
        // query whether or not
474
        if ($value == null && $default !== null) {
475
            $value = $default;
476
        }
477
478
        // return the value
479
        return $value;
480
    }
481
482
    /**
483
     * Return's the Magento configuration value.

src/Subjects/AbstractSubject.php 1 location

@@ 389-417 (lines=29) @@
386
     *
387
     * @return mixed|null The, almost formatted, value
388
     */
389
    public function getValue($name, $default = null, callable $callback = null)
390
    {
391
392
        // initialize the value
393
        $value = null;
394
395
        // query whether or not the header is available
396
        if ($this->hasHeader($name)) {
397
            // load the header value
398
            $headerValue = $this->getHeader($name);
399
            // query wheter or not, the value with the requested key is available
400
            if ((isset($this->row[$headerValue]) && $this->row[$headerValue] != '')) {
401
                $value = $this->row[$headerValue];
402
            }
403
        }
404
405
        // query whether or not, a callback has been passed
406
        if ($value != null && is_callable($callback)) {
407
            $value = call_user_func($callback, $value);
408
        }
409
410
        // query whether or not
411
        if ($value == null && $default !== null) {
412
            $value = $default;
413
        }
414
415
        // return the value
416
        return $value;
417
    }
418
419
    /**
420
     * Tries to format the passed value to a valid date with format 'Y-m-d H:i:s'.