Completed
Pull Request — master (#63)
by .
03:06
created

ClientConfiguration   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 52
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 7
lcom 1
cbo 0
dl 0
loc 52
ccs 14
cts 14
cp 1
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 1
A getUri() 0 4 1
A getOptions() 0 4 1
A cleanOptions() 0 9 4
1
<?php declare(strict_types=1);
2
3
namespace Facile\MongoDbBundle\Models;
4
5
/**
6
 * Class ClientConfiguration.
7
 * @internal
8
 */
9
final class ClientConfiguration
10
{
11
    /** @var string */
12
    private $uri;
13
    /** @var array */
14
    private $options;
15
16
    /**
17
     * ClientConfiguration constructor.
18
     *
19
     * @param string $uri
20
     * @param array $options
21
     */
22 31
    public function __construct(
23
        string $uri,
24
        array $options = []
25
    ) {
26 31
        $this->uri = $uri;
27 31
        $this->options = $options;
28 31
    }
29
30
    /**
31
     * @return string
32
     */
33 29
    public function getUri(): string
34
    {
35 29
        return $this->uri;
36
    }
37
38
    /**
39
     * @return array
40
     */
41 29
    public function getOptions(): array
42
    {
43 29
        return $this->cleanOptions($this->options);
44
    }
45
46
    /**
47
     * @param array $options
48
     *
49
     * @return array
50
     */
51 29
    private function cleanOptions(array $options): array
52
    {
53 29
        return array_filter(
54 29
            $options,
55 29
            function ($value) {
56 3
                return ! empty($value) || \is_int($value) || \is_bool($value) || \is_float($value);
57 29
            }
58
        );
59
    }
60
}
61