also looking at this
meemalabs/laravel-text-to-speech
Apply fixes from StyleCI
#10
2 files
+19
-25
Review threads live on the whole diff, not on one commit, so none are shown here - a thread's line means something in the branch's final form, and painting it into an intermediate step would put it on code it is not about.
| @@ -8,13 +8,13 @@ use RecursiveIterator; | ||
| 8 | 8 | class RecursiveDOMIterator implements RecursiveIterator |
| 9 | 9 | { |
| 10 | 10 | /** |
| 11 | * Current Position in DOMNodeList | |
| 12 | * @var Integer | |
| 11 | * Current Position in DOMNodeList. | |
| 12 | * @var int | |
| 13 | 13 | */ |
| 14 | 14 | protected $_position; |
| 15 | 15 | |
| 16 | 16 | /** |
| 17 | * The DOMNodeList with all children to iterate over | |
| 17 | * The DOMNodeList with all children to iterate over. | |
| 18 | 18 | * @var DOMNodeList |
| 19 | 19 | */ |
| 20 | 20 | protected $_nodeList; |
| @@ -30,7 +30,7 @@ class RecursiveDOMIterator implements RecursiveIterator | ||
| 30 | 30 | } |
| 31 | 31 | |
| 32 | 32 | /** |
| 33 | * Returns the current DOMNode | |
| 33 | * Returns the current DOMNode. | |
| 34 | 34 | * @return DOMNode |
| 35 | 35 | */ |
| 36 | 36 | public function current() |
| @@ -39,7 +39,7 @@ class RecursiveDOMIterator implements RecursiveIterator | ||
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | /** |
| 42 | * Returns an iterator for the current iterator entry | |
| 42 | * Returns an iterator for the current iterator entry. | |
| 43 | 43 | * @return RecursiveDOMIterator |
| 44 | 44 | */ |
| 45 | 45 | public function getChildren() |
| @@ -49,7 +49,7 @@ class RecursiveDOMIterator implements RecursiveIterator | ||
| 49 | 49 | |
| 50 | 50 | /** |
| 51 | 51 | * Returns if an iterator can be created for the current entry. |
| 52 | * @return Boolean | |
| 52 | * @return bool | |
| 53 | 53 | */ |
| 54 | 54 | public function hasChildren() |
| 55 | 55 | { |
| @@ -57,8 +57,8 @@ class RecursiveDOMIterator implements RecursiveIterator | ||
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | /** |
| 60 | * Returns the current position | |
| 61 | * @return Integer | |
| 60 | * Returns the current position. | |
| 61 | * @return int | |
| 62 | 62 | */ |
| 63 | 63 | public function key() |
| 64 | 64 | { |
| @@ -75,7 +75,7 @@ class RecursiveDOMIterator implements RecursiveIterator | ||
| 75 | 75 | } |
| 76 | 76 | |
| 77 | 77 | /** |
| 78 | * Rewind the Iterator to the first element | |
| 78 | * Rewind the Iterator to the first element. | |
| 79 | 79 | * @return void |
| 80 | 80 | */ |
| 81 | 81 | public function rewind() |
| @@ -84,8 +84,8 @@ class RecursiveDOMIterator implements RecursiveIterator | ||
| 84 | 84 | } |
| 85 | 85 | |
| 86 | 86 | /** |
| 87 | * Checks if current position is valid | |
| 88 | * @return Boolean | |
| 87 | * Checks if current position is valid. | |
| 88 | * @return bool | |
| 89 | 89 | */ |
| 90 | 90 | public function valid() |
| 91 | 91 | { |
| @@ -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 | } | |