BookRenterPriceClient   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 1
dl 0
loc 30
ccs 18
cts 18
cp 1
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A getPricesForIsbns() 0 9 2
A addMetaToPrices() 0 9 2
1
<?php namespace Packback\Prices\Clients;
2
3
class BookRenterPriceClient extends CommissionJunctionPriceClient
4
{
5
    const RETAILER = 'bookrenter';
6
7 2
    public function __construct($config = [])
8
    {
9 2
        $cj_config = array_merge($config['cj'], $config[self::RETAILER]);
10 2
        parent::__construct($cj_config);
11 2
    }
12
13 2
    public function getPricesForIsbns($isbns = [])
14
    {
15 2
        foreach ($isbns as $isbn) {
16 2
            $response = $this->addParam('isbn', $isbn)->send();
17 2
            $this->addPricesToCollection($response);
18 2
        }
19 2
        $this->addMetaToPrices($this->collection);
20 2
        return $this->collection;
21
    }
22
23 2
    private function addMetaToPrices($prices = [])
24
    {
25 2
        foreach ($prices as $i => $price) {
26 2
            $prices[$i]->retailer = self::RETAILER;
27 2
            $prices[$i]->condition = parent::CONDITION_NEW;
28 2
            $prices[$i]->term = parent::TERM_SEMESTER;
29 2
        }
30 2
        return $prices;
31
    }
32
}
33