Passed
Pull Request — master (#921)
by
unknown
08:01
created

Gtin::isValid()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 3

Importance

Changes 0
Metric Value
eloc 3
dl 0
loc 6
ccs 4
cts 4
cp 1
rs 10
c 0
b 0
f 0
cc 3
nc 2
nop 1
crap 3
1
<?php
2
3
/**
4
 * Class for validation of GTIN
5
 *
6
 * @category  NFePHP
7
 * @package   NFePHP\NFe\Common\Config
8
 * @copyright NFePHP Copyright (c) 2008-2019
9
 * @license   http://www.gnu.org/licenses/lgpl.txt LGPLv3+
10
 * @license   https://opensource.org/licenses/MIT MIT
11
 * @license   http://www.gnu.org/licenses/gpl.txt GPLv3+
12
 * @author    Roberto L. Machado <linux.rlm at gmail dot com>
13
 * @link      http://github.com/nfephp-org/sped-nfe for the canonical source repository
14
 */
15
16
namespace NFePHP\NFe\Common;
17
18
use NFePHP\Gtin\Gtin as GB;
19
20
class Gtin
21
{
22
    /**
23
     * Verify if GTIN is valid with dv
24
     * @param string $gtin
25
     * @return boolean
26
     */
27 4
    public static function isValid($gtin)
28
    {
29 4
        if ($gtin === '' || $gtin === 'SEM GTIN') {
30 2
            return true;
31
        }
32 4
        return GB::check($gtin)->isValid();
33
    }
34
}
35