Completed
Push — master ( 896361...d387da )
by Ronan
02:51
created

Udi   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A validate() 0 11 2
1
<?php
2
3
namespace IsoCodes;
4
5
/**
6
 * Class UDI:  Unique Device Identification, the DI component, up to 14 digits GTIN
7
 * GTINs may be 8, 12, 13 or 14-digits in length.
8
 * Their data structures require up to 14-digit fields
9
 * and all GTIN processing software should allow for 14 digits.
10
 *
11
 * @link http://www.idtechnology.com/uploads/whitepapers/UDI_eBook.pdf
12
 * @link https://accessgudid.nlm.nih.gov/about-gudid#what-is-udi
13
 * @link http://www.gs1.org/healthcare/udi
14
 */
15
class Udi extends Gtin14 implements IsoCodeInterface
16
{
17
    /**
18
     * @param mixed $di - Device Identifier component
19
     *
20
     * @return bool
21
     */
22
    public static function validate($di)
23
    {
24
        $di = self::unDecorate($di);
25
        $validUdiLength = [8, 12, 13, 14];
26
        $length = strlen($di);
27
        if (!in_array($length, $validUdiLength)) {
28
            return false;
29
        }
30
31
        return parent::check($di, $length);
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