Passed
Pull Request — master (#78)
by
unknown
14:55
created

SimpleSaleRepository   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Importance

Changes 3
Bugs 0 Features 1
Metric Value
eloc 12
dl 0
loc 42
rs 10
c 3
b 0
f 1
wmc 8
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-2020, HiQDev (http://hiqdev.com/)
9
 */
10
11
namespace hiqdev\php\billing\tests\support\sale;
12
13
use Exception;
14
use hiqdev\php\billing\action\ActionInterface;
15
use hiqdev\php\billing\order\OrderInterface;
16
use hiqdev\php\billing\sale\SaleInterface;
17
use hiqdev\php\billing\sale\SaleRepositoryInterface;
18
use hiqdev\DataMapper\Query\Specification;
19
use DateTimeImmutable;
20
21
class SimpleSaleRepository implements SaleRepositoryInterface
22
{
23
    protected $sale;
24
25
    public function __construct(?SaleInterface $sale = null)
26
    {
27
        $this->sale = $sale;
28
    }
29
30
    public function findId(SaleInterface $sale)
31
    {
32
        return $this->sale->getId();
33
    }
34
35
    public function findByAction(ActionInterface $action)
36
    {
37
        return $this->sale;
38
    }
39
40
    public function findByOrder(OrderInterface $order)
41
    {
42
        $sales = [];
43
        foreach ($order->getActions() as $actionKey => $action) {
44
            $sales[$actionKey] = $this->findByAction($action);
45
        }
46
47
        return $sales;
48
    }
49
50
    public function findAllActive(Specification $specification, ?DateTimeImmutable $time): array
51
    {
52
        throw new Exception('not implemented');
53
    }
54
55
    public function findByIds(array $ids)
56
    {
57
        throw new Exception('not implemented');
58
    }
59
60
    public function findById(string $id): ?object
61
    {
62
        throw new Exception('not implemented');
63
    }
64
}
65