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.

Rest::call()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
c 0
b 0
f 0
rs 9.4285
cc 2
eloc 4
nc 2
nop 2
1
<?php
2
3
namespace Saltwater\RedBean\Service;
4
5
use Saltwater\Server as S;
6
use Saltwater\Utils as U;
7
use Saltwater\Salt\Service;
8
9
class Rest extends Service
10
{
11
    public function isCallable($method)
12
    {
13
        if (parent::isCallable($method)) {
14
            return true;
15
        }
16
17
        $class = U::explodeClass($this);
18
19
        return strpos($method, array_pop($class)) !== false;
20
    }
21
22
    /**
23
     * @param object $call
24
     * @param mixed  $data
25
     *
26
     * @return array|int|\RedBean_OODBBean
27
     */
28
    public function call($call, $data = null)
29
    {
30
        if (parent::isCallable($call->function)) {
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (isCallable() instead of call()). Are you sure this is correct? If so, you might want to change this to $this->isCallable().

This check looks for a call to a parent method whose name is different than the method from which it is called.

Consider the following code:

class Daddy
{
    protected function getFirstName()
    {
        return "Eidur";
    }

    protected function getSurName()
    {
        return "Gudjohnsen";
    }
}

class Son
{
    public function getFirstName()
    {
        return parent::getSurname();
    }
}

The getFirstName() method in the Son calls the wrong method in the parent class.

Loading history...
31
            return parent::call($call, $data);
32
        }
33
34
        return $this->restCall($call, $data);
0 ignored issues
show
Bug Compatibility introduced by
The expression $this->restCall($call, $data); of type array|RedBean_OODBBean|null|integer|string adds the type string to the return on line 34 which is incompatible with the return type documented by Saltwater\RedBean\Service\Rest::call of type array|integer|RedBean_OODBBean.
Loading history...
35
    }
36
37
    /**
38
     * @param object $call
39
     * @param mixed  $data
40
     *
41
     * @return array|int|\RedBean_OODBBean
42
     */
43
    protected function restCall($call, $data = null)
44
    {
45
        $path = $call->method;
46
47
        if (is_numeric($call->path)) {
48
            $path .= '/' . $call->path;
49
        }
50
51
        return $this->callPath($call->http, $path, $data);
52
    }
53
54
    /**
55
     * @param string $http
56
     * @param string $path
57
     * @param mixed  $data
58
     */
59
    protected function callPath($http, $path, $data = null)
60
    {
61
        $rest = $this->restHandler();
62
63
        return $rest->handleRESTRequest($http, $path, $data);
64
    }
65
66
    protected function restHandler()
67
    {
68
        return new \RedBean_Plugin_BeanCan(S::$n->db($this->module));
69
    }
70
}
71