Completed
Push — master ( 484013...7348d2 )
by Ronan
02:45
created

Gdti   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A validate() 0 13 3
1
<?php
2
3
namespace IsoCodes;
4
5
/**
6
 * Class Gdti for GS1 Global Document Type Identifier (GDTI)
7
 * used by companies to identify documents, including the class or type of each document.
8
 *
9
 * @link http://www.gs1.org/global-document-type-identifier-gdti
10
 * @link http://www.gs1.org/docs/idkeys/GS1_GDTI_Executive_Summary.pdf
11
 * @link https://en.wikipedia.org/wiki/Global_Document_Type_Identifier
12
 */
13
class Gdti extends Gtin13 implements IsoCodeInterface
14
{
15
    /**
16
     * @param mixed $grai
17
     *
18
     * @return bool
19
     */
20
    public static function validate($grai)
21
    {
22
        if (strlen($grai) < 13) {
23
            return false;
24
        }
25
        $grai = self::unDecorate($grai);
26
        if (strlen($grai) > 30) {
27
            return false;
28
        }
29
        $gtin13 = substr($grai, 0, 13);
30
31
        return parent::check($gtin13, 13); // optional serial component not to be checked
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (check() instead of validate()). Are you sure this is correct? If so, you might want to change this to $this->check().

This check looks for a call to a parent method whose name is different than the method from which it is called.

Consider the following code:

class Daddy
{
    protected function getFirstName()
    {
        return "Eidur";
    }

    protected function getSurName()
    {
        return "Gudjohnsen";
    }
}

class Son
{
    public function getFirstName()
    {
        return parent::getSurname();
    }
}

The getFirstName() method in the Son calls the wrong method in the parent class.

Loading history...
32
    }
33
}
34