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 ( fad287...99c177 )
by
unknown
20s queued 11s
created

Vk::createRequest()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 7
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
1
<?php
2
3
/*
4
 * (c) Christian Gripp <[email protected]>
5
 *
6
 * For the full copyright and license information, please view the LICENSE
7
 * file that was distributed with this source code.
8
 */
9
10
namespace Core23\ShariffBundle\Service;
11
12
use Psr\Http\Message\RequestFactoryInterface;
13
use Psr\Http\Message\RequestInterface;
14
use Psr\Http\Message\ResponseInterface;
15
16
final class Vk implements Service
17
{
18
    public function getCode(): string
19
    {
20
        return 'vk';
21
    }
22
23
    public function createRequest(RequestFactoryInterface $factory, string $url): RequestInterface
24
    {
25
        return $factory->createRequest(
26
            'GET',
27
            'https://vk.com/share.php?act=count&index=1&url='.urlencode($url)
28
        );
29
    }
30
31
    public function count(ResponseInterface $response): int
32
    {
33
        $content = $response->getBody()->getContents();
34
        $content = mb_substr($content, 18, mb_strlen($content) - 20);
35
36
        return (int) $content ?? 0;
37
    }
38
}
39