1 | <?php |
||
10 | class NytController extends Controller |
||
11 | { |
||
12 | |||
13 | /** |
||
14 | * Instance of Guzzle Client |
||
15 | * @var object |
||
16 | */ |
||
17 | protected $client; |
||
18 | |||
19 | /** |
||
20 | * BaseUrl |
||
21 | * @var string |
||
22 | */ |
||
23 | protected $baseUrl; |
||
24 | |||
25 | /** |
||
26 | * Initialize the Controller with necessary arguments |
||
27 | */ |
||
28 | public function __construct() |
||
36 | |||
37 | /** |
||
38 | * Get the response from New York times API |
||
39 | * @param string $relativeUrl |
||
40 | */ |
||
41 | private function setGetResponse($relativeUrl) |
||
45 | |||
46 | /** |
||
47 | * Get the whole response from a get operation |
||
48 | * @return array |
||
49 | */ |
||
50 | private function getResponse() |
||
54 | |||
55 | /** |
||
56 | * Get the data response from a get operation |
||
57 | * @return array |
||
58 | */ |
||
59 | private function getData() |
||
63 | |||
64 | /** |
||
65 | * Return all the data to the New York times API dashboard |
||
66 | * @return array |
||
67 | */ |
||
68 | public function getPage() |
||
74 | } |
||
75 |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: