also looking at this
meemalabs/laravel-text-to-speech
Apply fixes from StyleCI
#10
2 files
+19
-25
| @@ -19,8 +19,7 @@ class WebsiteSource implements SourceContract | ||
| 19 | 19 | { |
| 20 | 20 | $articles = $this->getDOMDocumentArticle($data); |
| 21 | 21 | |
| 22 | if ($articles === null) | |
| 23 | { | |
| 22 | if ($articles === null) { | |
| 24 | 23 | return ''; |
| 25 | 24 | } |
| 26 | 25 | |
| @@ -38,8 +37,7 @@ class WebsiteSource implements SourceContract | ||
| 38 | 37 | @$dom->loadHTML(file_get_contents($url)); |
| 39 | 38 | $element = $dom->getElementsByTagName('article')->item(0); |
| 40 | 39 | |
| 41 | if ($element !== null) | |
| 42 | { | |
| 40 | if ($element !== null) { | |
| 43 | 41 | return $element->childNodes; |
| 44 | 42 | } |
| 45 | 43 | } |
| @@ -54,11 +52,9 @@ class WebsiteSource implements SourceContract | ||
| 54 | 52 | { |
| 55 | 53 | $text = ''; |
| 56 | 54 | |
| 57 | for ($i = 0; $i < $articles->length; $i++) | |
| 58 | { | |
| 55 | for ($i = 0; $i < $articles->length; $i++) { | |
| 59 | 56 | // Check element if there is a childNodes |
| 60 | if ($articles->item($i)->childNodes === null) | |
| 61 | { | |
| 57 | if ($articles->item($i)->childNodes === null) { | |
| 62 | 58 | continue; |
| 63 | 59 | } |
| 64 | 60 | |
| @@ -66,15 +62,13 @@ class WebsiteSource implements SourceContract | ||
| 66 | 62 | new RecursiveDOMIterator($articles->item($i)), |
| 67 | 63 | RecursiveIteratorIterator::SELF_FIRST |
| 68 | 64 | ); |
| 69 | foreach ($dit as $node) | |
| 70 | { | |
| 71 | if ($node->nodeName === 'p') | |
| 72 | { | |
| 65 | foreach ($dit as $node) { | |
| 66 | if ($node->nodeName === 'p') { | |
| 73 | 67 | $text .= $node->textContent; |
| 74 | 68 | } |
| 75 | 69 | } |
| 76 | 70 | } |
| 77 | ||
| 71 | ||
| 78 | 72 | return $text; |
| 79 | 73 | } |
| 80 | }⧵ | |
| 74 | } | |