SentryLoggerConfig::setOptions()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 3
c 0
b 0
f 0
rs 10
cc 1
eloc 1
nc 1
nop 1
1
<?php
2
3
namespace Dasao\SentryLogger\Log;
4
5
use ReflectionClass;
6
use ReflectionException;
7
8
/**
9
 * Class SentryLoggerConfig
10
 *
11
 * PHP Version 7
12
 *
13
 * @category  PHP
14
 * @package   Dasao\SentryLogger\Log
15
 * @author    Dasao <[email protected]>
16
 * @copyright 2014-2017 Dasao
17
 * @license   Proprietary http://www.das-ao.com
18
 */
19
class SentryLoggerConfig implements SentryLoggerConfigInterface
20
{
21
    /** @var string */
22
    protected $dsn;
23
    /** @var array */
24
    protected $options;
25
26
    /**
27
     * @return string
28
     */
29
    public function getDsn() : string
30
    {
31
        return $this->dsn;
32
    }
33
34
    /**
35
     * @param string $dsn
36
     *
37
     * @return void
38
     */
39
    public function setDsn(string $dsn)
40
    {
41
        $this->dsn = $dsn;
42
    }
43
44
    /**
45
     * @return array
46
     */
47
    public function getOptions() : array
48
    {
49
        return $this->options;
50
    }
51
52
    /**
53
     * @param array $options
54
     *
55
     * @return void
56
     */
57
    public function setOptions(array $options)
58
    {
59
        $this->options = $options;
60
    }
61
62
    /**
63
     * Exchange array to properties.
64
     *
65
     * @param array $data The data to exchange.
66
     *
67
     * @return void
68
     * @throws ReflectionException
69
     */
70
    public function exchangeArray(array $data)
71
    {
72
        $reflection = new ReflectionClass($this);
73
        $properties = $reflection->getProperties();
74
75
        foreach ($properties as $property) {
76
            $propertyName = $property->getName();
77
78
            if (isset($data[$propertyName])) {
79
                $this->{$propertyName} = $data[$propertyName];
80
            }
81
        }
82
    }
83
}
84