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.

MonarManager   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 63
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 6
lcom 0
cbo 3
dl 0
loc 63
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A bbs() 0 17 3
A startsWith() 0 4 2
1
<?php
2
3
namespace Localdisk\Monar;
4
5
use GuzzleHttp\Client;
6
use Illuminate\Contracts\Foundation\Application;
7
8
class MonarManager implements Factory
9
{
10
    /**
11
     * @var string
12
     */
13
    public const SHITARABA = 'https://jbbs.shitaraba.net';
14
15
    /**
16
     * @var string
17
     */
18
    protected $url;
19
20
    /**
21
     * The application instance.
22
     *
23
     * @var \Illuminate\Contracts\Foundation\Application
24
     */
25
    protected $app;
26
27
    /**
28
     * MonarManager constructor.
29
     *
30
     * @param \Illuminate\Contracts\Foundation\Application $app
31
     */
32
    public function __construct(Application $app)
33
    {
34
        $this->app = $app;
35
    }
36
37
    /**
38
     * @param null $url
39
     *
40
     * @return Driver
41
     */
42
    public function bbs($url = null): Driver
43
    {
44
        if (null === $url) {
45
            throw new \InvalidArgumentException('Drivier is null');
46
        }
47
48
        $client = new Client([
49
            'cookies' => true,
50
            'http_errors' => false,
51
        ]);
52
53
        if ($this->startsWith($url, self::SHITARABA)) {
54
            return new ShitarabaDriver($url, $client);
55
        }
56
57
        return new TwoChanDriver($url, $client);
58
    }
59
60
    /**
61
     * @param string $haystack
62
     * @param string $needle
63
     *
64
     * @return bool
65
     */
66
    protected function startsWith($haystack, $needle): bool
67
    {
68
        return $needle !== '' && mb_strpos($haystack, $needle) === 0;
69
    }
70
}
71