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 — 3.x ( 854d93...81f322 )
by Jindřich
01:52
created

SkautisQuery   A

Complexity

Total Complexity 12

Size/Duplication

Total Lines 149
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 97.5%

Importance

Changes 0
Metric Value
wmc 12
lcom 1
cbo 0
dl 0
loc 149
ccs 39
cts 40
cp 0.975
rs 10
c 0
b 0
f 0

7 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 10 1
A serialize() 0 13 3
A unserialize() 0 11 1
A done() 0 8 1
A getExceptionClass() 0 8 2
A getExceptionString() 0 8 2
A hasFailed() 0 4 2
1
<?php
2
declare(strict_types = 1);
3
4
namespace Skautis;
5
6
/**
7
 * Trida slouzici pro debugovani SOAP pozadvku na servery Skautisu
8
 */
9
class SkautisQuery implements \Serializable
10
{
11
12
    /**
13
     * @var string Nazev funkce volane pomoci SOAP requestu
14
     */
15
    public $fname;
16
17
    /**
18
     * @var array Parametry SOAP requestu na server
19
     */
20
    public $args;
21
22
    /**
23
     * @var array Zasobnik volanych funkci
24
     */
25
    public $trace;
26
27
    /**
28
     * @var float Doba trvani pozadvku
29
     */
30
    public $time;
31
32
    public $result;
33
34
    /**
35
     * V pripade ze SOAP pozadavek selze
36
     *
37
     * Nelze povolit uzivateli primy pristup kvuli serializaci. Ne vsechny exceptions jdou serializovat.
38
     *
39
     * @var \Exception|null
40
     */
41
    protected $exception = null;
42
43
    /**
44
     * Po unserializaci Query s exception je zde jeji trida
45
     *
46
     * @var string
47
     */
48
    protected $exceptionClass = '';
49
50
    /**
51
     * Po unserializaci je zde text exxception
52
     *
53
     * Pouziva __toString() methodu
54
     *
55
     * @var string
56
     */
57
    protected $exceptionString = '';
58
59
    /**
60
     *
61
     *
62
     * @param string $fname Nazev volane funkce
63
     * @param array  $args  Argumenty pozadavku
64
     * @param array $trace Zasobnik volanych funkci
65
     */
66 6
    public function __construct(
67
      string $fname,
0 ignored issues
show
Coding Style introduced by
Multi-line function declaration not indented correctly; expected 8 spaces but found 6
Loading history...
68
      array $args = [],
0 ignored issues
show
Coding Style introduced by
Multi-line function declaration not indented correctly; expected 8 spaces but found 6
Loading history...
69
      array $trace = []
0 ignored issues
show
Coding Style introduced by
Multi-line function declaration not indented correctly; expected 8 spaces but found 6
Loading history...
70
    ) {
71 6
        $this->fname = $fname;
72 6
        $this->args = $args;
73 6
        $this->trace = $trace;
74 6
        $this->time = -microtime(true);
0 ignored issues
show
Documentation Bug introduced by
The property $time was declared of type double, but -microtime(true) is of type integer. Maybe add a type cast?

This check looks for assignments to scalar types that may be of the wrong type.

To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.

$answer = 42;

$correct = false;

$correct = (bool) $answer;
Loading history...
75 6
    }
76
77 2
    public function serialize()
78
    {
79
        $data = [
80 2
            'fname' => $this->fname,
81 2
            'args' => $this->args,
82 2
            'trace' => $this->trace,
83 2
            'time' => $this->time,
84 2
            'result' => $this->result,
85 2
            'exception_class' => $this->exception === null ? '' : get_class($this->exception),
86 2
            'exception_string' => $this->exception === null ? '' : (string)$this->exception,
87
        ];
88 2
        return serialize($data);
89
    }
90
91 2
    public function unserialize($data)
92
    {
93 2
        $data = unserialize($data);
94 2
        $this->fname = (string) $data['fname'];
95 2
        $this->args = (array) $data['args'];
96 2
        $this->trace = (array) $data['trace'];
97 2
        $this->time = (float) $data['time'];
98 2
        $this->result = $data['result'];
99 2
        $this->exceptionClass = (string) $data['exception_class'];
100 2
        $this->exceptionString = (string) $data['exception_string'];
101 2
    }
102
103
    /**
104
     * Oznac pozadavek za dokonceny a uloz vysledek
105
     *
106
     * @param mixed $result Odpoved ze serveru
107
     * @param \Exception $e Výjimka v pripade problemu
108
     */
109 6
    public function done($result = null, \Exception $e = null)
110
    {
111 6
        $this->time += microtime(true);
112 6
        $this->result = $result;
113 6
        $this->exception = $e;
114
115 6
        return $this;
116
    }
117
118
    /**
119
     * Vrati tridu exception
120
     *
121
     * Pouziva se tato metoda protoze SoapFault exception vyhozena SoapClientem nejde serializovat
122
     *
123
     * @return string
124
     */
125 5
    public function getExceptionClass(): string
126
    {
127 5
        if ($this->exception === null) {
128 2
            return $this->exceptionClass;
129
        }
130
131 3
        return get_class($this->exception);
132
    }
133
134
    /**
135
     * Vrati textovou podobu exception
136
     *
137
     * @return string
138
     */
139 2
    public function getExceptionString(): string
140
    {
141 2
        if ($this->exception === null) {
142
            return $this->exceptionString;
143
        }
144
145 2
        return (string)$this->exception;
146
    }
147
148
    /**
149
     * Kontrola jestli se pozadavek zdaril
150
     *
151
     * @return bool
152
     */
153 6
    public function hasFailed(): bool
154
    {
155 6
        return $this->exception !== null || strlen($this->exceptionClass) > 0;
156
    }
157
}
158