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.

HashAlgorithm::__toString()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 1
1
<?php
2
3
namespace Ogone;
4
5
class HashAlgorithm
6
{
7
    const HASH_SHA1 = 'sha1';
8
    const HASH_SHA256 = 'sha256';
9
    const HASH_SHA512 = 'sha512';
10
11
    /** @var string */
12
    private $algorithm;
13
14
    /**
15
     * @param $algorithm
16
     * @throws \InvalidArgumentException
17
     */
18 12
    public function __construct($algorithm)
19
    {
20 12
        if (!in_array($algorithm, array(self::HASH_SHA1, self::HASH_SHA256, self::HASH_SHA512))) {
21 1
            throw new \InvalidArgumentException(
22 1
                $algorithm . ' is not supported, only sha1, sha256 and sha512 are allowed.'
23
            );
24
        }
25
26 11
        $this->algorithm = $algorithm;
27 11
    }
28
29 11
    public function __toString()
30
    {
31 11
        return (string) $this->algorithm;
32
    }
33
}
34