Save   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 6
c 1
b 0
f 0
dl 0
loc 18
ccs 4
cts 4
cp 1
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
/**
10
 * @template TItem of \Swis\JsonApi\Client\Interfaces\ItemInterface
11
 */
12
trait Save
13
{
14
    /** @use Create<TItem> */
15
    use Create { create as protected saveNew; }
16
17
    /** @use Update<TItem> */
18
    use Update { update as protected saveExisting; }
19
20
    /**
21
     * @return \Swis\JsonApi\Client\Interfaces\ItemDocumentInterface<TItem>
22
     */
23 8
    public function save(ItemInterface $item, array $parameters = [], array $headers = [])
24
    {
25 8
        if ($item->isNew()) {
26 4
            return $this->saveNew($item, $parameters, $headers);
27
        }
28
29 4
        return $this->saveExisting($item, $parameters, $headers);
30
    }
31
}
32