@@ -47,7 +47,7 @@ private function populateOptions(array $options = []): array
4747 * film name is passed instead of film-id
4848 * @param string $film
4949 * @param array $options
50- * @return array $filmData
50+ * @return array $response
5151 */
5252 public function film (string $ film , array $ options = []): array
5353 {
@@ -58,15 +58,19 @@ public function film(string $film, array $options = []): array
5858 // -> handles what the api returns
5959 $ response = new Response ;
6060
61+ // Initiate dom object
62+ // -> handles page scraping
6163 $ dom = new Dom ;
64+
65+ // Load imdb page and parse the dom
6266 $ page = $ dom ->fetch ("https://www.imdb.com/title/tt0816692/ " , $ options );
6367
64- return [
65- " id " => " tt0816692 " ,
66- " title " => " Interstellar " ,
67- " length " => " 2h 49min " ,
68- " year " => " 2014 "
69- ] ;
68+ $ response -> add ( " id " , " tt0816692 " );
69+ $ response -> add ( " title " , " Interstellar " );
70+ $ response -> add ( " length " , " 2h 49min " );
71+ $ response -> add ( " year " , " 2014 " );
72+
73+ return $ response -> return () ;
7074 }
7175
7276 /**
@@ -80,11 +84,15 @@ public function search(string $search, array $options = []): array
8084 // Combine user options with default ones
8185 $ options = $ this ->populateOptions ($ options );
8286
83- return [
84- "titles " => [],
85- "names " => [],
86- "companies " => []
87- ];
87+ // Initiate response object
88+ // -> handles what the api returns
89+ $ response = new Response ;
90+
91+ $ response ->add ("titles " , []);
92+ $ response ->add ("names " , []);
93+ $ response ->add ("companies " , []);
94+
95+ return $ response ->return ();
8896 }
8997
9098}
0 commit comments