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   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 0
dl 0
loc 29
ccs 8
cts 8
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 10 2
A __toString() 0 4 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