Code Duplication    Length = 36-36 lines in 2 locations

src/Datium.php 2 locations

@@ 407-442 (lines=36) @@
404
     *
405
     * @return object
406
     */
407
    public function add($value)
408
    {
409
410
        $this->date_interval_expression = str_replace(
411
            $this->config['date_simple'],
412
            $this->config['date_interval'],
413
            $value
414
        );
415
416
        $unit = 'P';
417
418
        if (strpos($this->date_interval_expression, 'T')) {
419
            $this->date_interval_expression = str_replace(
420
                'T',
421
                '',
422
                $this->date_interval_expression
423
            );
424
425
            $unit = 'PT';
426
        }
427
428
        $this->date_interval_expression = str_replace(
429
            ' ',
430
            '',
431
            $unit.$this->date_interval_expression
432
        );
433
434
        $this->date_time->add(
435
            new DateInterval($this->date_interval_expression)
436
        );
437
438
        return $this;
439
440
    }
441
442
    /**
443
     * Sub date from current date
444
     *
445
     * @param string $value How much date should increase from current date
@@ 449-484 (lines=36) @@
446
     *
447
     * @return obejct
448
     */
449
    public function sub($value)
450
    {
451
452
        $this->date_interval_expression = str_replace(
453
            $this->config['date_simple'],
454
            $this->config['date_interval'],
455
            $value
456
        );
457
458
        $unit = 'P';
459
460
        if (strpos($this->date_interval_expression, 'T')) {
461
            $this->date_interval_expression = str_replace(
462
                'T',
463
                '',
464
                $this->date_interval_expression
465
            );
466
467
            $unit = 'PT';
468
        }
469
470
        $this->date_interval_expression = str_replace(
471
            ' ',
472
            '',
473
            $unit.$this->date_interval_expression
474
        );
475
476
        $this->date_time->sub(
477
            new DateInterval($this->date_interval_expression)
478
        );
479
480
        return $this;
481
482
    }
483
484
    /**
485
     * Check if current year is leap or not
486
     *
487
     * @param string $type Name of the calendar to caculate leap year