UpdateTrait   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 7
c 0
b 0
f 0
dl 0
loc 17
rs 10
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A update() 0 10 2
1
<?php
2
3
namespace Helix\Asana\Base\AbstractEntity;
4
5
use Helix\Asana\Base\AbstractEntity;
6
7
/**
8
 * Adds `update()` to entities.
9
 *
10
 * @mixin AbstractEntity
11
 */
12
trait UpdateTrait {
13
14
    /**
15
     * `PUT` the data diff to Asana, if there is one.
16
     *
17
     * @return $this
18
     */
19
    public function update () {
20
        if ($this->isDiff()) {
21
            /** @var array $remote */
22
            $remote = $this->api->put($this, $this->toArray(true), ['expand' => 'this']);
23
            $this->_setData($remote);
24
            /** @var AbstractEntity $that */
25
            $that = $this;
26
            $this->api->getPool()->add($that);
27
        }
28
        return $this;
29
    }
30
}