Completed
Push — master ( 1cdde8...6d8ac3 )
by Andrii
03:17
created

TargetRepository   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 1
dl 0
loc 18
ccs 0
cts 3
cp 0
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 10 1
1
<?php
2
3
namespace hiqdev\billing\hiapi\repositories;
4
5
use hiapi\components\ConnectionInterface;
6
use hiqdev\php\billing\target\TargetFactoryInterface;
7
8
class TargetRepository extends \hiapi\repositories\BaseRepository
9
{
10
    /**
11
     * @var TargetFactoryInterface
12
     */
13
    protected $factory;
14
15
    public function __construct(
16
        ConnectionInterface $db,
17
        TargetFactoryInterface $factory,
18
        array $config = []
19
    ) {
20
        parent::__construct($config);
21
22
        $this->db = $db;
0 ignored issues
show
Documentation introduced by
The property db does not exist on object<hiqdev\billing\hi...ories\TargetRepository>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
23
        $this->factory = $factory;
24
    }
25
}
26