Completed
Push — master ( a4f70a...5b7a0f )
by Andrii
05:16
created

SimplePlanRepository   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 5
lcom 1
cbo 1
dl 0
loc 29
rs 10
c 1
b 0
f 1

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A findByAction() 0 4 1
A findByOrder() 0 9 2
A findByIds() 0 4 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\order\OrderInterface;
15
use hiqdev\php\billing\plan\PlanInterface;
16
use hiqdev\php\billing\plan\PlanRepositoryInterface;
17
18
class SimplePlanRepository implements PlanRepositoryInterface
19
{
20
    protected $plan;
21
22
    public function __construct(PlanInterface $plan)
23
    {
24
        $this->plan = $plan;
25
    }
26
27
    public function findByAction(ActionInterface $action)
28
    {
29
        return $this->plan;
30
    }
31
32
    public function findByOrder(OrderInterface $order)
33
    {
34
        $plans = [];
35
        foreach (array_keys($order->getActions()) as $actionKey) {
36
            $plans[$actionKey] = $this->plan;
37
        }
38
39
        return $plans;
40
    }
41
42
    public function findByIds(array $ids)
43
    {
44
        throw new \Exception('not implemented');
45
    }
46
}
47