StatusGuesser   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A isOk() 0 9 3
A isFailed() 0 4 1
1
<?php
2
3
/*
4
 * This file is part of the hogosha-monitor package
5
 *
6
 * Copyright (c) 2016 Guillaume Cavana
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 *
11
 * Feel free to edit as you please, and have fun.
12
 *
13
 * @author Guillaume Cavana <[email protected]>
14
 */
15
16
namespace Hogosha\Monitor\Guesser;
17
18
use Hogosha\Monitor\Model\Result;
19
20
/**
21
 * Class StatusGuesser.
22
 */
23
class StatusGuesser
24
{
25
    const IDENTIFIED = 1;
26
    const RESOLVED = 0;
27
28
    /**
29
     * isOk.
30
     *
31
     * @param Result $result
32
     *
33
     * @return bool Return true is the condition is true
34
     */
35
    public function isOk(Result $result)
36
    {
37
        //The validator is used, so we can apply the rule
38
        if (null !== $result->getValidatorResult()) {
39
            return ($result->getUrl()->getExpectedStatus() == $result->getStatusCode()) && $result->getValidatorResult();
40
        }
41
42
        return $result->getUrl()->getExpectedStatus() == $result->getStatusCode();
43
    }
44
45
    /**
46
     * isFailed.
47
     *
48
     * @param Result $result
49
     *
50
     * @return bool Return true is the condition is false
51
     */
52
    public function isFailed(Result $result)
53
    {
54
        return !$this->isOk($result);
55
    }
56
}
57