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 — 0.9 (#694)
by
unknown
03:32
created

PrimeNumber::validate()   B

Complexity

Conditions 7
Paths 5

Size

Total Lines 18
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 10
CRAP Score 7

Importance

Changes 3
Bugs 1 Features 0
Metric Value
dl 0
loc 18
ccs 10
cts 10
cp 1
rs 8.2222
c 3
b 1
f 0
cc 7
eloc 9
nc 5
nop 1
crap 7
1
<?php
2
namespace Respect\Validation\Rules;
3
4
class PrimeNumber extends AbstractRule
5
{
6 18
    public function validate($input)
7
    {
8 18
        if (!is_numeric($input) || $input <= 1) {
9 8
            return false;
10
        }
11
12 10
        if ($input != 2 && ($input % 2) ==  0) {
13 2
            return false;
14
        }
15
16 8
        for ($i = 3; $i <= ceil(sqrt($input)); $i+=2) {
17 6
            if (($input % $i) == 0) {
18 2
                return false;
19
            }
20 6
        }
21
22 6
        return true;
23
    }
24
}
25