@@ -77,7 +77,7 @@ public function get(object $page, string $element)
7777 $ findAllCast = $ dom ->find ($ page , 'table.cast_list tr ' );
7878 foreach ($ findAllCast as $ castRow )
7979 {
80- if (count ($ castRow ->find ('.primary_photo ' )) === 0 ) {
80+ if ($ this -> count ($ castRow ->find ('.primary_photo ' )) === 0 ) {
8181 continue ;
8282 }
8383 $ actor = [];
@@ -87,7 +87,7 @@ public function get(object $page, string $element)
8787
8888 $ actorRow = $ castRow ->find ('td ' )[1 ];
8989 $ actorLink = $ actorRow ->find ('a ' );
90- if (count ($ actorLink ) > 0 ) {
90+ if ($ this -> count ($ actorLink ) > 0 ) {
9191 // Set actor name to text within link
9292 $ actor ["actor " ] = $ actorLink ->text ;
9393 $ actor ["actor_id " ] = $ this ->extractImdbId ($ actorLink ->href );
@@ -109,7 +109,7 @@ public function get(object $page, string $element)
109109 case "technical_specs " :
110110 $ technical_specs = [];
111111 $ table = $ dom ->find ($ page , '.dataTable tr ' );
112- if (count ($ table ) > 0 ) {
112+ if ($ this -> count ($ table ) > 0 ) {
113113 foreach ($ table as $ row )
114114 {
115115 $ row_title = $ row ->find ('td ' )[0 ]->text (true );
@@ -129,14 +129,14 @@ public function get(object $page, string $element)
129129 case "companies " :
130130 $ response = [];
131131 $ sections = $ page ->find (".findSection " );
132- if (count ($ sections ) > 0 )
132+ if ($ this -> count ($ sections ) > 0 )
133133 {
134134 foreach ($ sections as $ section )
135135 {
136136 $ sectionName = @strtolower ($ section ->find (".findSectionHeader " )->text );
137137 if ($ sectionName === $ element ) {
138138 $ sectionRows = $ section ->find (".findList tr " );
139- if (count ($ sectionRows ) > 0 )
139+ if ($ this -> count ($ sectionRows ) > 0 )
140140 {
141141 foreach ($ sectionRows as $ sectionRow )
142142 {
@@ -210,8 +210,9 @@ public function strClean($string)
210210 * @param array|string $item
211211 * @return string
212212 */
213- private function count ($ item ) {
214- return (is_array ($ item ) ? count ($ item ) : strlen ($ item ));
213+ private function count ($ item )
214+ {
215+ return (is_countable ($ item ) ? count ($ item ) : (is_string ($ item ) ? strlen ($ item ) : 0 ));
215216 }
216217
217218}
0 commit comments