Issues (12)

src/Api/Api.php (2 issues)

Labels
Severity
1
<?php
2
3
namespace Sreedev\Slack\Api;
4
5
class Api 
6
{    
7
    /**
8
     * Slack
9
     *
10
     * @var mixed
11
     */
12
    private $Slack;
13
    
14
    /**
15
     * endPoints
16
     *
17
     * @var mixed
18
     */
19
    private $endPoints;
20
    
21
    /**
22
     * functionSet
23
     *
24
     * @var mixed
25
     */
26
    private  $functionSet;
27
    
28
    /**
29
     * __construct
30
     *
31
     * @param  mixed $Slack
32
     * @param  mixed $method
33
     * @param  mixed $data
34
     * @return void
35
     */
36
    public function __construct(\Sreedev\Slack\Slack $Slack, $method, $data, $functionSet)
37
    {
38
        $this->Slack = $Slack;
39
        $this->setfunctionSet($functionSet);
40
        $json = file_get_contents(__DIR__. '/Slack.json');
41
        $this->endPoints = json_decode($json, true);
42
        return $this->sendRequest($method, $data);
0 ignored issues
show
Are you sure the usage of $this->sendRequest($method, $data) targeting Sreedev\Slack\Api\Api::sendRequest() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
43
    }
44
    
45
    /**
46
     * sendRequest
47
     *
48
     * @param  mixed $method
49
     * @param  mixed $data
50
     * @return void
51
     */
52
    private function sendRequest($method, $data)
53
    {
54
        $request = $this->endPoints[$this->functionSet.$method];
55
        return $this->execute(
0 ignored issues
show
Are you sure the usage of $this->execute($request[...request['path'], $data) targeting Sreedev\Slack\Api\Api::execute() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
56
            $request['method'], 
57
            $request['path'], 
58
            $data
59
        );
60
    }
61
     
62
    
63
    /**
64
     * execute
65
     *
66
     * @param  mixed $http_method
67
     * @param  mixed $method
68
     * @param  mixed $data
69
     * @return void
70
     */
71
    public function execute($http_method, $method, $data)
72
    {
73
        return $this->Slack->makeRequest($http_method, $method, $data);
74
    }
75
    
76
    /**
77
     * setfunctionSet
78
     *
79
     * @param  mixed $functionSet
80
     * @return void
81
     */
82
    private function setfunctionSet($functionSet)
83
    {
84
        $this->functionSet = $functionSet.".";
85
    }
86
}