Schemes   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 7
lcom 1
cbo 0
dl 0
loc 47
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 16 5
A last() 0 4 1
A getLast() 0 5 1
1
<?php
2
3
namespace NFePHP\eFinanc\Common;
4
5
/**
6
 * Locate and identify last version folder of schemes XSD
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 Schemes
16
{
17
    /**
18
     * @var string
19
     */
20
    private $lastschemes;
21
    
22
    /**
23
     * Constructor
24
     * Find last version scheme folder
25
     */
26
    public function __construct()
27
    {
28
        $scans = scandir('../schemes');
29
        $lastnumname = 0;
30
        $this->lastschemes = '';
31
        foreach ($scans as $folder) {
32
            if ($folder == '.' || $folder == '..') {
33
                continue;
34
            }
35
            $numname = str_replace(['v', '_'], '', $folder);
36
            if ($numname > $lastnumname) {
37
                $lastnumname = $numname;
38
                $this->lastschemes = str_replace('v', '', $folder);
39
            }
40
        }
41
    }
42
    
43
    /**
44
     * Return last scheme folder
45
     * @return string
46
     */
47
    public function last()
48
    {
49
        return $this->lastschemes;
50
    }
51
    
52
    /**
53
     * Return last scheme folder
54
     * @return string
55
     */
56
    public static function getLast()
57
    {
58
        $sch = new static();
59
        return $sch->last();
60
    }
61
}
62