ArrayHeaderConfigurator::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 1
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace MyBuilder\Bundle\CronosBundle\Exporter;
4
5
use MyBuilder\Cronos\Formatter\Header;
6
use Symfony\Component\PropertyAccess\PropertyAccessor;
7
8
class ArrayHeaderConfigurator
9
{
10
    /** @var string[] */
11
    private $configFields = ['mailto', 'path', 'shell', 'encoding', 'contentType', 'timezone'];
12
13
    /** @var Header */
14
    private $header;
15
16
    public function __construct(Header $header)
17
    {
18
        $this->header = $header;
19
    }
20
21
    public function configureFrom(array $config): Header
22
    {
23
        $propertyAccessor = new PropertyAccessor();
24
25
        foreach ($this->configFields as $configField) {
26
            if (isset($config[$configField])) {
27
                $propertyAccessor->setValue($this->header, $configField, $config[$configField]);
28
            }
29
        }
30
31
        return $this->header;
32
    }
33
}
34