OptionalConstructor::__construct()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 11
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 5
c 1
b 0
f 0
nc 3
nop 2
dl 0
loc 11
ccs 6
cts 6
cp 1
crap 3
rs 10
1
<?php
2
3
namespace Tarantool\SymfonyLock;
4
5
use Tarantool\Client\Client;
6
7
trait OptionalConstructor
8
{
9
    private Client $client;
10
11 17
    public function __construct(Client $client, array $options = [])
12
    {
13 17
        foreach ($options as $k => $v) {
14 8
            if (property_exists($this, $k)) {
15 8
                $this->$k = $options[$k];
16
            }
17
        }
18
19 17
        $this->client = $client;
20
21 17
        $this->validateOptions();
22 17
    }
23
24
    abstract protected function validateOptions();
25
}
26