Subresource::getSubresourceURI()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 3
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
c 3
b 0
f 0
nc 1
nop 1
dl 0
loc 6
rs 9.4285
1
<?php
2
3
namespace Clarify;
4
5
/**
6
 * Class Subresource
7
 * @package Clarify
8
 */
9
abstract class Subresource
10
{
11
    protected $subresource;
12
    protected $client = null;
13
    public $detail = null;
14
15
    public function __construct(\Clarify\Client $client)
16
    {
17
        $this->client = $client;
18
    }
19
20
    /**
21
     * @param $id
22
     * @return mixed
23
     */
24
    protected function getSubresourceURI($id)
25
    {
26
        $request = $this->client->get($id, array(), array('exceptions' => false));;
0 ignored issues
show
Unused Code introduced by
The call to Client::get() has too many arguments starting with array('exceptions' => false).

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
27
28
        return $request['_links'][$this->subresource]['href'];
29
    }
30
31
    /**
32
     * @param $id
33
     * @return array|bool|float|int|string
34
     */
35
    public function load($id)
36
    {
37
        $resourceURI = $this->getSubresourceURI($id);
38
39
        return $this->client->get($resourceURI);
40
    }
41
42
    /**
43
     * @param $id
44
     * @return bool
45
     */
46
    public function delete($id)
47
    {
48
        $resourceURI = $this->getSubresourceURI($id);
49
50
        return $this->client->delete($resourceURI);
51
    }
52
}