Scrutinizer GitHub App not installed

We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.

Install GitHub App

Completed
Pull Request — master (#651)
by Reginaldo
04:26
created

VisaCreditCard   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A validate() 0 6 2
A verifyIfCardIsVisa() 0 6 1
1
<?php
2
3
/*
4
 * This file is part of Respect/Validation.
5
 *
6
 * (c) Alexandre Gomes Gaigalas <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the "LICENSE.md"
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Respect\Validation\Rules;
13
14
class VisaCreditCard extends CreditCard
15
{
16
17 14
    public function validate($input)
18
    {
19 14
        $input = preg_replace('([^0-9])', '', $input);
20
        
21 14
        return parent::verifyMod10($input) && $this->verifyIfCardIsVisa($input);
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (verifyMod10() instead of validate()). Are you sure this is correct? If so, you might want to change this to $this->verifyMod10().

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...
22
    }
23
24 11
    private function verifyIfCardIsVisa($input)
25
    {
26 11
        $pattern = "/^4[0-9]{12,15}$/";//Visa
27
28 11
        return (preg_match($pattern, $input) > 0);
29
    }
30
31
}
32