UpdateTrait   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
c 1
b 0
f 0
dl 0
loc 15
rs 10
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A update() 0 9 2
1
<?php
2
3
namespace Helix\Shopify\Base\AbstractEntity;
4
5
use Helix\Shopify\Base\AbstractEntity;
6
7
/**
8
 * @mixin AbstractEntity
9
 */
10
trait UpdateTrait
11
{
12
13
    /**
14
     * @return $this
15
     */
16
    public function update()
17
    {
18
        assert($this->hasId());
0 ignored issues
show
Bug introduced by
It seems like hasId() 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

18
        assert($this->/** @scrutinizer ignore-call */ hasId());
Loading history...
19
        if ($this->isDiff()) {
0 ignored issues
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
            $remote = $this->api->put($this, [static::TYPE => $this->toDiff()]);
0 ignored issues
show
Bug introduced by
It seems like toDiff() 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

20
            $remote = $this->api->put($this, [static::TYPE => $this->/** @scrutinizer ignore-call */ toDiff()]);
Loading history...
Bug introduced by
The constant Helix\Shopify\Base\Abstr...ntity\UpdateTrait::TYPE was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
21
            $this->_setData($remote[static::TYPE]);
0 ignored issues
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

21
            $this->/** @scrutinizer ignore-call */ 
22
                   _setData($remote[static::TYPE]);
Loading history...
22
            $this->_onSave();
0 ignored issues
show
Bug introduced by
It seems like _onSave() 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
            $this->/** @scrutinizer ignore-call */ 
23
                   _onSave();
Loading history...
23
        }
24
        return $this;
25
    }
26
}