GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( ecf461...e116b7 )
by Vadim
15:02
created

MapperBuilder::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
namespace Newage\Annotations\Mapper;
4
5
use Newage\Annotations\Config\MapperBuilderConfig;
6
use Zend\Stdlib\ArrayObject;
7
use Zend\Config\Writer\PhpArray;
8
use Zend\Config\Reader;
9
10
/**
11
 * @package Newage\Annotations\Mapper
12
 */
13
class MapperBuilder implements MapperBuilderInterface
14
{
15
    const MAPPER_NAME = 'mapping.php';
16
17
    /**
18
     * Path to save generated maps
19
     * @var string
20
     */
21
    protected $buildPath;
22
23
    /**
24
     * @var MapperBuilderConfig
25
     */
26
    private $config;
27
28
    /**
29
     * MapperBuilder constructor.
30
     *
31
     * @param MapperBuilderConfig $config
32
     */
33
    public function __construct(MapperBuilderConfig $config)
34
    {
35
        $this->config = $config;
36
    }
37
38
    /**
39
     * Generate/update mapping
40
     * @param ArrayObject $spec
41
     */
42
    public function create(ArrayObject $spec)
43
    {
44
        $filePath = $this->config->getConfig('path') . self::MAPPER_NAME;
45
        $configArray = new ArrayObject();
46
47
        foreach ($spec['entities'] as $entity) {
48
            if (isset($entity['entity'])) {
49
                $configArray[$entity['entity']] = $entity;
50
                unset($entity['entity']);
51
            }
52
        }
53
54
        $writer = new PhpArray();
55
        $writer->setUseBracketArraySyntax(true);
56
        $writer->toFile($filePath, $configArray);
57
    }
58
}
59