Completed
Push — master ( 22330a...e8d007 )
by Dmitry
01:58
created

TargetRepository   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 2
dl 0
loc 23
ccs 0
cts 13
cp 0
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 10 1
A findOneById() 0 4 1
1
<?php
2
/**
3
 * API for Billing
4
 *
5
 * @link      https://github.com/hiqdev/billing-hiapi
6
 * @package   billing-hiapi
7
 * @license   BSD-3-Clause
8
 * @copyright Copyright (c) 2017, HiQDev (http://hiqdev.com/)
9
 */
10
11
namespace hiqdev\billing\hiapi\target;
12
13
use hiqdev\php\billing\target\Target;
14
use hiqdev\yii\DataMapper\components\ConnectionInterface;
15
use hiqdev\php\billing\target\TargetFactoryInterface;
16
use hiqdev\yii\DataMapper\query\Specification;
17
18
class TargetRepository extends \hiqdev\yii\DataMapper\repositories\BaseRepository
19
{
20
    /**
21
     * @var TargetFactoryInterface
22
     */
23
    protected $factory;
24
25
    public function __construct(
26
        ConnectionInterface $db,
27
        TargetFactoryInterface $factory,
28
        array $config = []
29
    ) {
30
        parent::__construct($config);
31
32
        $this->db = $db;
33
        $this->factory = $factory;
34
    }
35
36
    public function findOneById($id): ?Target
37
    {
38
        return $this->findOne((new Specification())->andWhere(['id' => $id]));
39
    }
40
}
41