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
Push — 0.9 ( 7d978d...1ce8ac )
by Henrique
07:01 queued 01:39
created

Zend::assert()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 15
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 9
CRAP Score 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 15
ccs 9
cts 9
cp 1
rs 9.4285
c 1
b 0
f 0
cc 3
eloc 8
nc 3
nop 1
crap 3
1
<?php
2
namespace Respect\Validation\Rules;
3
4
use ReflectionClass;
5
use Respect\Validation\Exceptions\ComponentException;
6
7
class Zend extends AbstractRule
8
{
9
    protected $messages = array();
10
    protected $zendValidator;
11
12 9
    public function __construct($validator, $params = array())
13
    {
14 9
        if (is_object($validator)) {
15 2
            return $this->zendValidator = $validator;
0 ignored issues
show
Bug introduced by
Constructors do not have meaningful return values, anything that is returned from here is discarded. Are you sure this is correct?
Loading history...
16
        }
17
18 7
        if (!is_string($validator)) {
19
            throw new ComponentException('Invalid Validator Construct');
20
        }
21
22 7
        if (false === stripos($validator, 'Zend')) {
23 6
            $validator = "Zend\\Validator\\{$validator}";
24 6
        } else {
25 1
            $validator = "\\{$validator}";
26
        }
27
28 7
        $zendMirror = new ReflectionClass($validator);
29
30 7
        if ($zendMirror->hasMethod('__construct')) {
31 7
            $this->zendValidator = $zendMirror->newInstanceArgs($params);
32 7
        } else {
33
            $this->zendValidator = $zendMirror->newInstance();
34
        }
35 7
    }
36
37 3
    public function assert($input)
38
    {
39 3
        $validator = clone $this->zendValidator;
40
41 3
        if ($validator->isValid($input)) {
42 1
            return true;
43
        }
44
45 2
        $exceptions = array();
46 2
        foreach ($validator->getMessages() as $m) {
47 2
            $exceptions[] = $this->reportError($m, get_object_vars($this));
48 2
        }
49
50 2
        throw $this->reportError($input)->setRelated($exceptions);
51
    }
52
53 3
    public function validate($input)
54
    {
55 3
        $validator = clone $this->zendValidator;
56
57 3
        return $validator->isValid($input);
58
    }
59
}
60