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 ( 912221...961991 )
by Gallice
05:44 queued 02:40
created

XHubSignature::validate()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

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
eloc 2
nc 1
nop 3
crap 1
1
<?php
2
3
namespace Tgallice\FBMessenger;
4
5
class XHubSignature
6
{
7
    const ALGORITHM = "sha1";
8
9
    /**
10
     * @param string $payload
11
     * @param string $secret
12
     * @param string $signature
13
     *
14
     * @return bool
15
     */
16 4
    public static function validate($payload, $secret, $signature)
17
    {
18 4
        return hash_equals(self::compute($payload, $secret), $signature);
19
    }
20
21
    /**
22
     * @param string $payload
23
     * @param string $secret
24
     *
25
     * @return string
26
     */
27 10
    public static function compute($payload, $secret)
28
    {
29 10
        return hash_hmac(self::ALGORITHM, $payload, $secret);
30
    }
31
32
    /**
33
     * @param string $header
34
     *
35
     * @return string
36
     */
37 4
    public static function parseHeader($header)
38
    {
39 4
        return substr($header, strpos($header, '=')+1);
40
    }
41
}
42