Completed
Push — master ( dbd16b...a17da9 )
by Steven
02:08
created

Products::getProduct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 1
crap 1
1
<?php namespace Stevenmaguire\Uber\Resources;
2
3
trait Products
4
{
5
    /**
6
     * Fetches a specific product.
7
     *
8
     * @param    string   $productId    Product id
9
     *
10
     * @return   stdClass               The JSON response from the request
11
     *
12
     * @see      https://developer.uber.com/docs/riders/references/api/v1.2/products-product_id-get
13
     */
14 2
    public function getProduct($productId)
15
    {
16 2
        return $this->request('get', 'products/'.$productId);
0 ignored issues
show
Bug introduced by
It seems like request() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
17
    }
18
19
    /**
20
     * Lists available products.
21
     *
22
     * The Products endpoint returns information about the Uber products
23
     * offered at a given location. The response includes the display name and
24
     * other details about each product, and lists the products in the proper
25
     * display order.
26
     *
27
     * Some Products, such as experiments or promotions such as UberPOOL and
28
     * UberFRESH, will not be returned by this endpoint.
29
     *
30
     * @param    array    $attributes   Query attributes
31
     *
32
     * @return   stdClass               The JSON response from the request
33
     *
34
     * @see      https://developer.uber.com/docs/riders/references/api/v1.2/products-get
35
     */
36 8
    public function getProducts($attributes = [])
37
    {
38 8
        return $this->request('get', 'products', $attributes);
0 ignored issues
show
Bug introduced by
It seems like request() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
39
    }
40
41
    /**
42
     * Updates a specific product properties for sandbox responses.
43
     *
44
     * @param    string   $productId    Product id
45
     * @param    array    $attributes   Query attributes
46
     *
47
     * @return   stdClass               The JSON response from the request
48
     * @throws   Exception
49
     *
50
     * @see      https://developer.uber.com/docs/riders/guides/sandbox#product-types
51
     */
52 4
    public function setSandboxProduct($productId, $attributes = [])
53
    {
54 4
        $this->enforceSandboxExpectation();
0 ignored issues
show
Bug introduced by
It seems like enforceSandboxExpectation() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
55
56 2
        return $this->request('put', 'sandbox/products/'.$productId, $attributes);
0 ignored issues
show
Bug introduced by
It seems like request() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
57
    }
58
}
59