Passed
Push — master ( 02e6b9...8f2f39 )
by y
01:57
created

DateTrait::setStartOn()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 2
rs 10
c 1
b 0
f 0
1
<?php
2
3
namespace Helix\Asana\Base\AbstractEntity;
4
5
use DateTimeInterface;
6
use Helix\Asana\Base\AbstractEntity;
7
8
/**
9
 * Adds date helpers.
10
 *
11
 * @mixin AbstractEntity
12
 *
13
 * @method null|string  getDueOn    () `Y-m-d`
14
 * @method bool         hasDueOn    ()
15
 * @method string       getStartOn  () `Y-m-d`
16
 * @method bool         hasStartOn  ()
17
 */
18
trait DateTrait {
19
20
    /**
21
     * @param string $field
22
     * @param null|string|DateTimeInterface $date
23
     * @return $this
24
     */
25
    private function _setYmd (string $field, $date) {
26
        if ($date instanceof DateTimeInterface) {
27
            $date = $date->format('Y-m-d');
28
        }
29
        return $this->_set($field, $date);
1 ignored issue
show
Bug introduced by
The method _set() does not exist on Helix\Asana\Base\AbstractEntity\DateTrait. Did you maybe mean _setYmd()? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

29
        return $this->/** @scrutinizer ignore-call */ _set($field, $date);

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
30
    }
31
32
    /**
33
     * @param null|string|DateTimeInterface $date
34
     * @return $this
35
     */
36
    public function setDueOn ($date) {
37
        return $this->_setYmd('due_on', $date);
38
    }
39
40
    /**
41
     * @param null|string|DateTimeInterface $date
42
     * @return $this
43
     */
44
    public function setStartOn ($date) {
45
        return $this->_setYmd('start_on', $date);
46
    }
47
48
}