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

Products   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 4
dl 0
loc 25
ccs 11
cts 11
cp 1
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A create() 0 9 1
A fetch() 0 5 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