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:33
created

CreditCardVisa   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 1 Features 0
Metric Value
wmc 5
c 1
b 1
f 0
lcom 0
cbo 1
dl 0
loc 30
ccs 12
cts 12
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A validate() 0 14 3
A verifyIfCardIsVisa() 0 10 2
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 CreditCardVisa extends CreditCard
15
{
16
17 14
    public function validate($input)
18
    {
19 14
        $input = preg_replace('([^0-9])', '', $input);
20
        
21 14
        if (empty($input)) {
22 3
            return false;
23
        }
24
25 11
        if (!$this->verifyMod10($input)) {
26 3
            return false;
27
        }
28
29 8
        return $this->verifyIfCardIsVisa($input);
30
    }
31
32 8
    private function verifyIfCardIsVisa($input)
33
    {
34 8
        $pattern = "/^([4]{1})([0-9]{12,15})$/";//Visa
35
36 8
        if (preg_match($pattern, $input)) {
37 5
            return true;
38
        }
39
40 3
        return false;
41
    }
42
43
}
44