Passed
Branch master (fc5382)
by Fabian
03:13
created

AbstractAuthorization   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 3
eloc 11
dl 0
loc 33
ccs 0
cts 7
cp 0
rs 10
c 2
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 2 1
A _isValid() 0 7 2
1
<?php
2
3
namespace LE_ACME2\Response\Authorization;
4
5
use LE_ACME2\Response\AbstractResponse;
6
7
use LE_ACME2\Connector\RawResponse;
8
use LE_ACME2\Exception;
9
10
class AbstractAuthorization extends AbstractResponse {
11
12
    // Status from RFC 8555 (7.1.4), version: March 2019
13
14
    const STATUS_PENDING = 'pending';
15
    const STATUS_VALID = 'valid';
16
    const STATUS_INVALID = 'invalid';
17
    const STATUS_DEACTIVATED = 'deactivated';
18
    const STATUS_EXPIRED = 'expired';
19
    const STATUS_REVOKED = 'revoked';
20
21
    /**
22
     * AbstractAuthorization constructor.
23
     * @param RawResponse $raw
24
     * @throws Exception\InvalidResponse
25
     * @throws Exception\RateLimitReached
26
     * @throws Exception\ExpiredAuthorization
27
     */
28
    public function __construct(RawResponse $raw) {
29
        parent::__construct($raw);
30
    }
31
32
    /**
33
     * @return bool
34
     * @throws Exception\ExpiredAuthorization
35
     */
36
    protected function _isValid() : bool {
37
38
        if($this->_preg_match_headerLine('/^HTTP\/.* 404/i') !== null) {
0 ignored issues
show
Bug introduced by
Are you sure the usage of $this->_preg_match_headerLine('/^HTTP\/.* 404/i') targeting LE_ACME2\Response\Abstra...preg_match_headerLine() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
introduced by
The condition $this->_preg_match_heade...TP\/.* 404/i') !== null is always false.
Loading history...
39
            throw new Exception\ExpiredAuthorization();
40
        }
41
42
        return parent::_isValid();
43
    }
44
}