Passed
Push — master ( bd5142...9b9e59 )
by y
01:36
created

UpdateTrait::onUpdate()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 1
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 0
nc 1
nop 0
dl 0
loc 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Helix\Asana\Base\AbstractEntity;
4
5
use Helix\Asana\Api;
6
use Helix\Asana\Base\AbstractEntity;
7
8
/**
9
 * Adds `update()` to entities.
10
 */
11
trait UpdateTrait {
12
13
    /**
14
     * `PUT` the data diff to Asana, if there is one.
15
     *
16
     * @return $this
17
     */
18
    public function update () {
19
        if ($this->isDiff()) {
1 ignored issue
show
Bug introduced by
It seems like isDiff() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

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

19
        if ($this->/** @scrutinizer ignore-call */ isDiff()) {
Loading history...
20
            /** @var Api $api */
21
            $api = $this->api;
22
            $remote = $api->put($this, $this->getDiff(), ['expand' => 'this']);
1 ignored issue
show
Bug introduced by
$this of type Helix\Asana\Base\AbstractEntity\UpdateTrait is incompatible with the type string expected by parameter $path of Helix\Asana\Api::put(). ( Ignorable by Annotation )

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

22
            $remote = $api->put(/** @scrutinizer ignore-type */ $this, $this->getDiff(), ['expand' => 'this']);
Loading history...
Bug introduced by
It seems like getDiff() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

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

22
            $remote = $api->put($this, $this->/** @scrutinizer ignore-call */ getDiff(), ['expand' => 'this']);
Loading history...
23
            $this->_setData($remote);
1 ignored issue
show
Bug introduced by
It seems like _setData() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

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

23
            $this->/** @scrutinizer ignore-call */ 
24
                   _setData($remote);
Loading history...
24
            /** @var AbstractEntity $that */
25
            $that = $this;
26
            $api->getCache()->add($that);
27
        }
28
        return $this;
29
    }
30
}