Passed
Push — master ( da6516...18010c )
by Gabriel
02:39
created

Products::fetch()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 5
ccs 3
cts 3
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 0
crap 1
1
<?php
2
3
namespace Waredesk;
4
5
use Waredesk\Mappers\ProductMapper;
6
use Waredesk\Mappers\ProductsMapper;
7
use Waredesk\Models\Product;
8
9
class Products
10
{
11
    private $requestHandler;
12
13 7
    public function __construct(RequestHandler $requestHandler)
14
    {
15 7
        $this->requestHandler = $requestHandler;
16 7
    }
17
18 2
    public function create(Product $product): Product
19
    {
20 2
        $response = $this->requestHandler->post(
21 2
            '/v1/products',
22
            $product
23
        );
24 2
        $product = (new ProductMapper())->map($product, $response);
25 2
        return $product;
26
    }
27
28 1
    public function fetch(): Collections\Products
29
    {
30 1
        $response = $this->requestHandler->get('/v1/products');
31 1
        return (new ProductsMapper())->map(new Collections\Products(), $response);
32
    }
33
}
34