Completed
Pull Request — master (#27)
by Farhad
05:00
created

ArrayHeaderConfigurator::setupShell()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

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