Completed
Push — master ( ed3ca4...bcd0d2 )
by Dmitry
11:49
created

SimplePlanRepository   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Importance

Changes 3
Bugs 0 Features 2
Metric Value
eloc 10
c 3
b 0
f 2
dl 0
loc 35
rs 10
wmc 6

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getById() 0 3 1
A findByOrder() 0 8 2
A findByAction() 0 3 1
A __construct() 0 3 1
A findByIds() 0 3 1
1
<?php
2
/**
3
 * PHP Billing Library
4
 *
5
 * @link      https://github.com/hiqdev/php-billing
6
 * @package   php-billing
7
 * @license   BSD-3-Clause
8
 * @copyright Copyright (c) 2017-2018, HiQDev (http://hiqdev.com/)
9
 */
10
11
namespace hiqdev\php\billing\tests\unit\plan;
12
13
use hiqdev\php\billing\action\ActionInterface;
14
use hiqdev\php\billing\Exception\EntityNotFoundException;
15
use hiqdev\php\billing\order\OrderInterface;
16
use hiqdev\php\billing\plan\PlanInterface;
17
use hiqdev\php\billing\plan\PlanRepositoryInterface;
18
19
class SimplePlanRepository implements PlanRepositoryInterface
20
{
21
    protected $plan;
22
23
    public function __construct(PlanInterface $plan)
24
    {
25
        $this->plan = $plan;
26
    }
27
28
    public function findByAction(ActionInterface $action)
29
    {
30
        return $this->plan;
31
    }
32
33
    public function findByOrder(OrderInterface $order)
34
    {
35
        $plans = [];
36
        foreach (array_keys($order->getActions()) as $actionKey) {
37
            $plans[$actionKey] = $this->plan;
38
        }
39
40
        return $plans;
41
    }
42
43
    public function findByIds(array $ids)
44
    {
45
        throw new \Exception('not implemented');
46
    }
47
48
    /**
49
     * @inheritDoc
50
     */
51
    public function getById(int $id): PlanInterface
52
    {
53
        throw new \Exception('not implemented');
54
    }
55
}
56