Completed
Pull Request — master (#63)
by .
05:38
created

ClientConfiguration::getPassword()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 1
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
    public function __construct(
23
        string $uri,
24
        array $options = []
25
    ) {
26
        $this->uri = $uri;
27
        $this->options = $options;
28
    }
29
30
    /**
31 35
     * @return string
32
     */
33
    public function getUri(): string
34
    {
35
        return $this->uri;
36
    }
37
38 35
    /**
39 35
     * @return array
40 35
     */
41 35
    public function getOptions(): array
42 35
    {
43 35
        return $this->cleanOptions($this->options);
44
    }
45
46
    /**
47
     * @param array $options
48 33
     *
49
     * @return array
50 33
     */
51
    private function cleanOptions(array $options): array
52
    {
53
        return array_filter(
54
            $options,
55
            function ($value) {
56 5
                return ! empty($value) || \is_int($value) || \is_bool($value) || \is_float($value);
57
            }
58 5
        );
59
    }
60
}
61