ResultException   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 90
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A isQueued() 0 4 1
A isRetry() 0 4 1
A isRedirect() 0 4 1
1
<?php
2
3
namespace Cronario\Exception;
4
5
use \Result\ResultException as IkResultException;
6
7
/**
8
 * Class ResultException
9
 *
10
 * @package Cronario\Exception
11
 */
12
class ResultException extends IkResultException
13
{
14
15
    /******************************************************************************
16
     * STATUS
17
     ******************************************************************************/
18
19
    const STATUS_RETRY = 'retry';
20
    const STATUS_REDIRECT = 'redirect';
21
    const STATUS_QUEUED = 'queued';
22
23
    /******************************************************************************
24
     * RESULTS
25
     ******************************************************************************/
26
27
    const R_QUEUED = 1;
28
    const R_RETRY = 6;
29
    const R_REDIRECT = 7;
30
    const FAILURE_MAX_ATTEMPTS = 8;
31
32
    /******************************************************************************
33
     * LOGIC
34
     *
35
     * COMMON                   codes 0xx
36
     *
37
     * FAILURE                  codes 2xx
38
     * ERROR                    codes 4xx
39
     *
40
     * RETRIES                  codes 6xx
41
     * REDIRECTS                codes 7xx
42
     * RETRIES + REDIRECTS      codes 8xx
43
     ******************************************************************************/
44
45
    /**
46
     * Common results scope with message and status
47
     *
48
     * @var array
49
     */
50
    public static $results
51
        = [
52
            self::R_QUEUED             => array(
53
                self::P_MESSAGE => 'queued ...',
54
                self::P_STATUS  => self::STATUS_QUEUED,
55
            ),
56
            self::R_REDIRECT           => array(
57
                self::P_MESSAGE => 'redirect ...',
58
                self::P_STATUS  => self::STATUS_REDIRECT,
59
            ),
60
            self::R_RETRY              => array(
61
                self::P_MESSAGE => 'retry ...',
62
                self::P_STATUS  => self::STATUS_RETRY,
63
            ),
64
            self::FAILURE_MAX_ATTEMPTS => array(
65
                self::P_MESSAGE => 'failure max retries ...',
66
                self::P_STATUS  => self::STATUS_FAILURE,
67
            ),
68
        ];
69
70
71
    /**
72
     * Check for 'queued' status
73
     *
74
     * @return boolean
75
     */
76 1
    public function isQueued()
77
    {
78 1
        return ($this->status === self::STATUS_QUEUED);
79
    }
80
81
    /**
82
     * Check for 'retry' status
83
     *
84
     * @return boolean
85
     */
86 3
    public function isRetry()
87
    {
88 3
        return ($this->status === self::STATUS_RETRY);
89
    }
90
91
    /**
92
     * Check for 'redirect' status
93
     *
94
     * @return boolean
95
     */
96 3
    public function isRedirect()
97
    {
98 3
        return ($this->status === self::STATUS_REDIRECT);
99
    }
100
101
}
102
103
104