1 | <?php namespace Stevenmaguire\Uber\Resources; |
||
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) |
|
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 = []) |
|
40 | |||
41 | /** |
||
42 | * Makes a request to the Uber API and returns the response. |
||
43 | * |
||
44 | * @param string $verb The Http verb to use |
||
45 | * @param string $path The path of the APi after the domain |
||
46 | * @param array $parameters Parameters |
||
47 | * |
||
48 | * @return stdClass The JSON response from the request |
||
49 | * @throws Exception |
||
50 | */ |
||
51 | abstract protected function request($verb, $path, $parameters = []); |
||
52 | |||
53 | /** |
||
54 | * Updates a specific product properties for sandbox responses. |
||
55 | * |
||
56 | * @param string $productId Product id |
||
57 | * @param array $attributes Query attributes |
||
58 | * |
||
59 | * @return stdClass The JSON response from the request |
||
60 | * @throws Exception |
||
61 | * |
||
62 | * @see https://developer.uber.com/docs/riders/guides/sandbox#product-types |
||
63 | */ |
||
64 | 4 | public function setSandboxProduct($productId, $attributes = []) |
|
70 | } |
||
71 |
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
The trait
Idable
provides a methodequalsId
that in turn relies on the methodgetId()
. 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.