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.

MapperBuilder   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 2
Bugs 0 Features 1
Metric Value
wmc 4
c 2
b 0
f 1
lcom 1
cbo 3
dl 0
loc 46
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A create() 0 16 3
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