Completed
Push — master ( d9b2af...484013 )
by Ronan
02:47
created

Grai   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A validate() 0 10 3
1
<?php
2
3
namespace IsoCodes;
4
5
/**
6
 * Class Grai for Global Returnable Asset Identifier, from GS1
7
 * Used for the management of reusable transport items, transport equipment, and tools.
8
 *
9
 * @link http://www.gs1.org/grai
10
 * @link https://en.wikipedia.org/wiki/Global_Returnable_Asset_Identifier
11
 */
12
class Grai extends Gtin13 implements IsoCodeInterface
13
{
14
    /**
15
     * @param mixed $grai
16
     *
17
     * @return bool
18
     */
19
    public static function validate($grai)
20
    {
21
        $grai = self::unDecorate($grai);
22
        if (strlen($grai) < 13 || strlen($grai) >= 30) {
23
            return false;
24
        }
25
        $gtin13 = substr($grai, 0, 13);
26
27
        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...
28
    }
29
}
30