Passed
Push — master ( d20c34...3db172 )
by Jasper
13:26
created

Save   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A save() 0 7 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Swis\JsonApi\Client\Actions;
6
7
use Swis\JsonApi\Client\Interfaces\ItemInterface;
8
9
trait Save
10
{
11
    use Create { create as protected saveNew; }
12
    use Update { update as protected saveExisting; }
13
14
    /**
15
     * @param \Swis\JsonApi\Client\Interfaces\ItemInterface $item
16
     * @param array                                         $parameters
17
     *
18
     * @return \Swis\JsonApi\Client\Interfaces\DocumentInterface
19
     */
20
    public function save(ItemInterface $item, array $parameters = [])
21
    {
22
        if ($item->isNew()) {
23
            return $this->saveNew($item, $parameters);
24
        }
25
26
        return $this->saveExisting($item, $parameters);
27
    }
28
}
29