Layouts   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 0
dl 0
loc 39
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 9 1
A read() 0 10 2
1
<?php
2
3
namespace NFePHP\eFinanc\Common;
4
5
/**
6
 * Locate and identify the version of each event
7
 *
8
 * @category  API
9
 * @package   NFePHP\eFinanc
10
 * @copyright Copyright (c) 2018
11
 * @license   http://www.gnu.org/licenses/lesser.html LGPL v3
12
 * @author    Roberto L. Machado <linux.rlm at gmail dot com>
13
 * @link      http://github.com/nfephp-org/sped-efinanceira for the canonical source repository
14
 */
15
class Layouts
16
{
17
    /**
18
     * @var array
19
     */
20
    public $versions;
21
    
22
    
23
    /**
24
     * Constructor
25
     * @param string $config
26
     */
27
    public function __construct($config)
28
    {
29
        $std = json_decode($config);
30
        $version = $std->eventoVersion;
31
        $schemasFolder = realpath(
32
            __DIR__."/../../schemes/v$version"
33
        );
34
        $this->read($schemasFolder);
35
    }
36
    
37
    /**
38
     * Locate folder indicated in config and read each xsd
39
     * extract version and save in property
40
     *
41
     * @param string $schemasFolder
42
     */
43
    protected function read($schemasFolder)
44
    {
45
        $list = glob($schemasFolder.'/*.xsd');
46
        foreach ($list as $file) {
47
            $xsd = str_replace($schemasFolder.'/', '', $file);
48
            $name = explode('-', $xsd);
49
            $ver = str_replace(['.xsd', 'v'], '', $name[1]);
50
            $this->versions[$name[0]] = $ver;
51
        }
52
    }
53
}
54