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   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 37
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 37
ccs 6
cts 6
cp 1
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A validate() 0 4 1
A compute() 0 4 1
A parseHeader() 0 4 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