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.

MethodOutOfScope::__construct()   A
last analyzed

Complexity

Conditions 2
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 3
nc 1
nop 4
dl 0
loc 6
rs 10
c 0
b 0
f 0
1
<?php
2
3
/*
4
 * This file is part of the ICanBoogie package.
5
 *
6
 * (c) Olivier Laviale <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace ICanBoogie\Prototype;
13
14
use BadMethodCallException;
15
use ICanBoogie\Accessor\AccessorTrait;
16
use Throwable;
17
18
use function get_class;
19
use function ICanBoogie\format;
20
21
/**
22
 * Exception thrown in attempt to invoke a method that is out of scope.
23
 *
24
 * @property-read string $method The method that is out of scope.
25
 * @property-read object $instance The instance on which the method was invoked.
26
 */
27
class MethodOutOfScope extends BadMethodCallException implements Exception
28
{
29
    /**
30
     * @uses get_method
31
     * @uses get_instance
32
     */
33
    use AccessorTrait;
34
35
    /**
36
     * @var string
37
     */
38
    private $method;
39
40
    private function get_method(): string
41
    {
42
        return $this->method;
43
    }
44
45
    /**
46
     * @var object
47
     */
48
    private $instance;
49
50
    private function get_instance(): object
51
    {
52
        return $this->instance;
53
    }
54
55
    /**
56
     * @inheritdoc
57
     */
58
    public function __construct(string $method, object $instance, string $message = null, Throwable $previous = null)
59
    {
60
        $this->method = $method;
0 ignored issues
show
Bug introduced by
The property method is declared read-only in ICanBoogie\Prototype\MethodOutOfScope.
Loading history...
61
        $this->instance = $instance;
0 ignored issues
show
Bug introduced by
The property instance is declared read-only in ICanBoogie\Prototype\MethodOutOfScope.
Loading history...
62
63
        parent::__construct($message ?: $this->format_message($method, $instance), 0, $previous);
64
    }
65
66
    private function format_message(string $method, object $instance): string
67
    {
68
        return format('The method %method is out of scope for class %class.', [
69
70
            'method' => $method,
71
            'class' => get_class($instance)
72
73
        ]);
74
    }
75
}
76