BookRenterPriceClient::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 5
ccs 4
cts 4
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 1
crap 1
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