GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( d4426a...04c02a )
by Boy
11:46 queued 08:30
created

OtpVerification::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 5
rs 9.4285
cc 1
eloc 3
nc 1
nop 2
1
<?php
2
3
/**
4
 * Copyright 2014 SURFnet bv
5
 *
6
 * Licensed under the Apache License, Version 2.0 (the "License");
7
 * you may not use this file except in compliance with the License.
8
 * You may obtain a copy of the License at
9
 *
10
 *     http://www.apache.org/licenses/LICENSE-2.0
11
 *
12
 * Unless required by applicable law or agreed to in writing, software
13
 * distributed under the License is distributed on an "AS IS" BASIS,
14
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
 * See the License for the specific language governing permissions and
16
 * limitations under the License.
17
 */
18
19
namespace Surfnet\StepupBundle\Service\SmsSecondFactor;
20
21
final class OtpVerification
22
{
23
    const STATUS_NO_MATCH = 0;
24
    const STATUS_MATCH_EXPIRED = 1;
25
    const STATUS_FOUND_MATCH = 2;
26
    const STATUS_TOO_MANY_ATTEMPTS = 3;
27
28
    /**
29
     * @var int
30
     */
31
    private $status;
32
33
    /**
34
     * @var null|string
35
     */
36
    private $phoneNumber;
37
38
    public static function noMatch()
39
    {
40
        return new self(self::STATUS_NO_MATCH);
41
    }
42
43
    public static function matchExpired()
44
    {
45
        return new self(self::STATUS_MATCH_EXPIRED);
46
    }
47
48
    public static function foundMatch($phoneNumber)
49
    {
50
        return new self(self::STATUS_FOUND_MATCH, $phoneNumber);
51
    }
52
53
    public static function tooManyAttempts()
54
    {
55
        return new self(self::STATUS_TOO_MANY_ATTEMPTS);
56
    }
57
58
    /**
59
     * @param int $status
60
     * @param string|null $phoneNumber
61
     */
62
    private function __construct($status, $phoneNumber = null)
63
    {
64
        $this->status = $status;
65
        $this->phoneNumber = $phoneNumber;
66
    }
67
68
    /**
69
     * @return bool
70
     */
71
    public function wasSuccessful()
72
    {
73
        return $this->status === self::STATUS_FOUND_MATCH;
74
    }
75
76
    /**
77
     * @return bool
78
     */
79
    public function didOtpMatch()
80
    {
81
        return $this->status === self::STATUS_FOUND_MATCH || $this->status === self::STATUS_MATCH_EXPIRED;
82
    }
83
    /**
84
     * @return bool
85
     */
86
    public function didOtpExpire()
87
    {
88
        return $this->status === self::STATUS_MATCH_EXPIRED;
89
    }
90
91
    /**
92
     * @return bool
93
     */
94
    public function wasAttemptedTooManyTimes()
95
    {
96
        return $this->status === self::STATUS_TOO_MANY_ATTEMPTS;
97
    }
98
99
    /**
100
     * @return null|string Only guaranteed to be a string when status is successful.
101
     */
102
    public function getPhoneNumber()
103
    {
104
        return $this->phoneNumber;
105
    }
106
}
107