We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
@@ -110,7 +110,7 @@ |
||
| 110 | 110 | * @param string $style The dash style. |
| 111 | 111 | * @param Settings $settings The current settings. |
| 112 | 112 | * |
| 113 | - * @return Dashes|null Returns null in case of an invalid $style parameter. |
|
| 113 | + * @return Simple_Dashes|null Returns null in case of an invalid $style parameter. |
|
| 114 | 114 | */ |
| 115 | 115 | public static function get_styled_dashes( $style, Settings $settings ) { |
| 116 | 116 | if ( isset( self::$styles[ $style ] ) ) { |
@@ -46,7 +46,7 @@ discard block |
||
| 46 | 46 | /** |
| 47 | 47 | * "International" dash style (using en dashes). |
| 48 | 48 | */ |
| 49 | - const INTERNATIONAL = 'international'; |
|
| 49 | + const INTERNATIONAL = 'international'; |
|
| 50 | 50 | |
| 51 | 51 | /** |
| 52 | 52 | * Available dash styles. |
@@ -112,13 +112,13 @@ discard block |
||
| 112 | 112 | * |
| 113 | 113 | * @return Dashes|null Returns null in case of an invalid $style parameter. |
| 114 | 114 | */ |
| 115 | - public static function get_styled_dashes( $style, Settings $settings ) { |
|
| 116 | - if ( isset( self::$styles[ $style ] ) ) { |
|
| 115 | + public static function get_styled_dashes($style, Settings $settings) { |
|
| 116 | + if (isset(self::$styles[$style])) { |
|
| 117 | 117 | return new Simple_Dashes( |
| 118 | - self::$styles[ $style ][ self::_PARENTHETICAL ], |
|
| 119 | - self::$styles[ $style ][ self::_PARENTHETICAL_SPACE ], |
|
| 120 | - self::$styles[ $style ][ self::_INTERVAL ], |
|
| 121 | - self::$styles[ $style ][ self::_INTERVAL_SPACE ] |
|
| 118 | + self::$styles[$style][self::_PARENTHETICAL], |
|
| 119 | + self::$styles[$style][self::_PARENTHETICAL_SPACE], |
|
| 120 | + self::$styles[$style][self::_INTERVAL], |
|
| 121 | + self::$styles[$style][self::_INTERVAL_SPACE] |
|
| 122 | 122 | ); |
| 123 | 123 | } |
| 124 | 124 | |
@@ -67,12 +67,12 @@ discard block |
||
| 67 | 67 | * |
| 68 | 68 | * @return Trie_Node |
| 69 | 69 | */ |
| 70 | - public function get_node( $char ) { |
|
| 71 | - if ( ! isset( $this->links[ $char ] ) ) { |
|
| 72 | - $this->links[ $char ] = new Trie_Node(); |
|
| 70 | + public function get_node($char) { |
|
| 71 | + if ( ! isset($this->links[$char])) { |
|
| 72 | + $this->links[$char] = new Trie_Node(); |
|
| 73 | 73 | } |
| 74 | 74 | |
| 75 | - return $this->links[ $char ]; |
|
| 75 | + return $this->links[$char]; |
|
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | /** |
@@ -82,8 +82,8 @@ discard block |
||
| 82 | 82 | * |
| 83 | 83 | * @return bool |
| 84 | 84 | */ |
| 85 | - public function exists( $char ) { |
|
| 86 | - return ! empty( $this->links[ $char ] ); |
|
| 85 | + public function exists($char) { |
|
| 86 | + return ! empty($this->links[$char]); |
|
| 87 | 87 | } |
| 88 | 88 | |
| 89 | 89 | /** |
@@ -102,17 +102,17 @@ discard block |
||
| 102 | 102 | * |
| 103 | 103 | * @return Trie_Node The starting node of the trie. |
| 104 | 104 | */ |
| 105 | - public static function build_trie( array $patterns ) { |
|
| 105 | + public static function build_trie(array $patterns) { |
|
| 106 | 106 | $trie = new Trie_Node(); |
| 107 | 107 | |
| 108 | - foreach ( $patterns as $key => $pattern ) { |
|
| 108 | + foreach ($patterns as $key => $pattern) { |
|
| 109 | 109 | $node = $trie; |
| 110 | 110 | |
| 111 | - foreach ( Strings::mb_str_split( $key ) as $char ) { |
|
| 112 | - $node = $node->get_node( $char ); |
|
| 111 | + foreach (Strings::mb_str_split($key) as $char) { |
|
| 112 | + $node = $node->get_node($char); |
|
| 113 | 113 | } |
| 114 | 114 | |
| 115 | - preg_match_all( '/([1-9])/S', $pattern, $offsets, PREG_OFFSET_CAPTURE ); |
|
| 115 | + preg_match_all('/([1-9])/S', $pattern, $offsets, PREG_OFFSET_CAPTURE); |
|
| 116 | 116 | $node->offsets = $offsets[1]; |
| 117 | 117 | } |
| 118 | 118 | |
@@ -48,8 +48,8 @@ discard block |
||
| 48 | 48 | * @param string $lang A language code. |
| 49 | 49 | * @param Hyphenator $hyphenator The object to cache. |
| 50 | 50 | */ |
| 51 | - public function set_hyphenator( $lang, Hyphenator $hyphenator ) { |
|
| 52 | - $this->cache[ $lang ] = $hyphenator; |
|
| 51 | + public function set_hyphenator($lang, Hyphenator $hyphenator) { |
|
| 52 | + $this->cache[$lang] = $hyphenator; |
|
| 53 | 53 | } |
| 54 | 54 | |
| 55 | 55 | /** |
@@ -59,9 +59,9 @@ discard block |
||
| 59 | 59 | * |
| 60 | 60 | * @return Hyphenator|null |
| 61 | 61 | */ |
| 62 | - public function get_hyphenator( $lang ) { |
|
| 63 | - if ( isset( $this->cache[ $lang ] ) ) { |
|
| 64 | - return $this->cache[ $lang ]; |
|
| 62 | + public function get_hyphenator($lang) { |
|
| 63 | + if (isset($this->cache[$lang])) { |
|
| 64 | + return $this->cache[$lang]; |
|
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | return null; |
@@ -79,12 +79,12 @@ discard block |
||
| 79 | 79 | * @throws \BadMethodCallException If the constructor is called twice. |
| 80 | 80 | * @throws \UnexpectedValueException If the type attribute is outside the allowed range. |
| 81 | 81 | */ |
| 82 | - public function __construct( $value, $type = self::WORD ) { |
|
| 83 | - if ( false === $this->mutable ) { |
|
| 84 | - throw new \BadMethodCallException( 'Constructor called twice.' ); |
|
| 82 | + public function __construct($value, $type = self::WORD) { |
|
| 83 | + if (false === $this->mutable) { |
|
| 84 | + throw new \BadMethodCallException('Constructor called twice.'); |
|
| 85 | 85 | } |
| 86 | 86 | |
| 87 | - switch ( $type ) { |
|
| 87 | + switch ($type) { |
|
| 88 | 88 | case self::SPACE: |
| 89 | 89 | case self::PUNCTUATION: |
| 90 | 90 | case self::WORD: |
@@ -93,13 +93,13 @@ discard block |
||
| 93 | 93 | break; |
| 94 | 94 | |
| 95 | 95 | default: |
| 96 | - throw new \UnexpectedValueException( "Invalid type $type." ); |
|
| 96 | + throw new \UnexpectedValueException("Invalid type $type."); |
|
| 97 | 97 | } |
| 98 | 98 | |
| 99 | - if ( ! isset( $value ) || ! is_string( $value ) ) { |
|
| 100 | - throw new \UnexpectedValueException( 'Value has to be a string.' ); |
|
| 99 | + if ( ! isset($value) || ! is_string($value)) { |
|
| 100 | + throw new \UnexpectedValueException('Value has to be a string.'); |
|
| 101 | 101 | } else { |
| 102 | - $this->value = $value; |
|
| 102 | + $this->value = $value; |
|
| 103 | 103 | } |
| 104 | 104 | |
| 105 | 105 | $this->mutable = false; |
@@ -112,8 +112,8 @@ discard block |
||
| 112 | 112 | * |
| 113 | 113 | * @return mixed |
| 114 | 114 | */ |
| 115 | - public function __get( $property ) { |
|
| 116 | - if ( property_exists( $this, $property ) ) { |
|
| 115 | + public function __get($property) { |
|
| 116 | + if (property_exists($this, $property)) { |
|
| 117 | 117 | return $this->$property; |
| 118 | 118 | } |
| 119 | 119 | } |
@@ -127,8 +127,8 @@ discard block |
||
| 127 | 127 | * |
| 128 | 128 | * @throws \BadMethodCallException The Token class is immutable. |
| 129 | 129 | */ |
| 130 | - public function __set( $id, $val ) { |
|
| 131 | - throw new \BadMethodCallException( 'Object of class Text_Parser\Token is immutable.' ); |
|
| 130 | + public function __set($id, $val) { |
|
| 131 | + throw new \BadMethodCallException('Object of class Text_Parser\Token is immutable.'); |
|
| 132 | 132 | } |
| 133 | 133 | |
| 134 | 134 | /** |
@@ -139,8 +139,8 @@ discard block |
||
| 139 | 139 | * |
| 140 | 140 | * @throws \BadMethodCallException The Token class is immutable. |
| 141 | 141 | */ |
| 142 | - public function __unset( $id ) { |
|
| 143 | - throw new \BadMethodCallException( 'Object of class Text_Parser\Token is immutable.' ); |
|
| 142 | + public function __unset($id) { |
|
| 143 | + throw new \BadMethodCallException('Object of class Text_Parser\Token is immutable.'); |
|
| 144 | 144 | } |
| 145 | 145 | |
| 146 | 146 | /** |
@@ -151,8 +151,8 @@ discard block |
||
| 151 | 151 | * |
| 152 | 152 | * @return Token |
| 153 | 153 | */ |
| 154 | - public function with_value( $value ) { |
|
| 155 | - if ( $this->value === $value ) { |
|
| 154 | + public function with_value($value) { |
|
| 155 | + if ($this->value === $value) { |
|
| 156 | 156 | return $this; |
| 157 | 157 | } |
| 158 | 158 | |
@@ -40,7 +40,7 @@ |
||
| 40 | 40 | * |
| 41 | 41 | * @return array |
| 42 | 42 | */ |
| 43 | - public static function array_map_assoc( callable $callable, array $array ) { |
|
| 44 | - return array_column( array_map( $callable, array_keys( $array ), $array ), 1, 0 ); |
|
| 43 | + public static function array_map_assoc(callable $callable, array $array) { |
|
| 44 | + return array_column(array_map($callable, array_keys($array), $array), 1, 0); |
|
| 45 | 45 | } |
| 46 | 46 | } |
@@ -332,7 +332,6 @@ |
||
| 332 | 332 | * Retrieves the tag name of the nearest block-level parent. |
| 333 | 333 | * |
| 334 | 334 | * @param \DOMNode $element A node. |
| 335 | - |
|
| 336 | 335 | * @return string The tag name (or the empty string). |
| 337 | 336 | */ |
| 338 | 337 | public static function get_block_parent_name( \DOMNode $element ) { |
@@ -48,13 +48,13 @@ discard block |
||
| 48 | 48 | * |
| 49 | 49 | * @return array |
| 50 | 50 | */ |
| 51 | - public static function block_tags( $reset = false ) { |
|
| 52 | - if ( empty( self::$block_tags ) || $reset ) { |
|
| 51 | + public static function block_tags($reset = false) { |
|
| 52 | + if (empty(self::$block_tags) || $reset) { |
|
| 53 | 53 | self::$block_tags = array_merge( |
| 54 | - array_flip( array_filter( array_keys( \Masterminds\HTML5\Elements::$html5 ), function( $tag ) { |
|
| 55 | - return \Masterminds\HTML5\Elements::isA( $tag, \Masterminds\HTML5\Elements::BLOCK_TAG ); |
|
| 56 | - } ) ), |
|
| 57 | - array_flip( [ 'li', 'td', 'dt' ] ) // not included as "block tags" in current HTML5-PHP version. |
|
| 54 | + array_flip(array_filter(array_keys(\Masterminds\HTML5\Elements::$html5), function($tag) { |
|
| 55 | + return \Masterminds\HTML5\Elements::isA($tag, \Masterminds\HTML5\Elements::BLOCK_TAG); |
|
| 56 | + } )), |
|
| 57 | + array_flip(['li', 'td', 'dt']) // not included as "block tags" in current HTML5-PHP version. |
|
| 58 | 58 | ); |
| 59 | 59 | } |
| 60 | 60 | |
@@ -69,11 +69,11 @@ discard block |
||
| 69 | 69 | * |
| 70 | 70 | * @return array An associative array in the form ( $spl_object_hash => $node ). |
| 71 | 71 | */ |
| 72 | - public static function nodelist_to_array( \DOMNodeList $list ) { |
|
| 72 | + public static function nodelist_to_array(\DOMNodeList $list) { |
|
| 73 | 73 | $out = []; |
| 74 | 74 | |
| 75 | - foreach ( $list as $node ) { |
|
| 76 | - $out[ spl_object_hash( $node ) ] = $node; |
|
| 75 | + foreach ($list as $node) { |
|
| 76 | + $out[spl_object_hash($node)] = $node; |
|
| 77 | 77 | } |
| 78 | 78 | |
| 79 | 79 | return $out; |
@@ -87,10 +87,10 @@ discard block |
||
| 87 | 87 | * |
| 88 | 88 | * @return array An array of \DOMNode. |
| 89 | 89 | */ |
| 90 | - public static function get_ancestors( \DOMNode $node ) { |
|
| 90 | + public static function get_ancestors(\DOMNode $node) { |
|
| 91 | 91 | $result = []; |
| 92 | 92 | |
| 93 | - while ( ( $node = $node->parentNode ) && ( $node instanceof \DOMElement ) ) { // @codingStandardsIgnoreLine. |
|
| 93 | + while (($node = $node->parentNode) && ($node instanceof \DOMElement)) { // @codingStandardsIgnoreLine. |
|
| 94 | 94 | $result[] = $node; |
| 95 | 95 | } |
| 96 | 96 | |
@@ -106,26 +106,26 @@ discard block |
||
| 106 | 106 | * |
| 107 | 107 | * @return boolean True if the element has any of the given class(es). |
| 108 | 108 | */ |
| 109 | - public static function has_class( \DOMNode $tag, $classnames ) { |
|
| 110 | - if ( $tag instanceof \DOMText ) { |
|
| 109 | + public static function has_class(\DOMNode $tag, $classnames) { |
|
| 110 | + if ($tag instanceof \DOMText) { |
|
| 111 | 111 | $tag = $tag->parentNode; // @codingStandardsIgnoreLine. |
| 112 | 112 | } |
| 113 | 113 | |
| 114 | 114 | // Bail if we are not working with a tag or if there is no classname. |
| 115 | - if ( ! ( $tag instanceof \DOMElement ) || empty( $classnames ) ) { |
|
| 115 | + if ( ! ($tag instanceof \DOMElement) || empty($classnames)) { |
|
| 116 | 116 | return false; |
| 117 | 117 | } |
| 118 | 118 | |
| 119 | 119 | // Ensure we always have an array of classnames. |
| 120 | - if ( ! is_array( $classnames ) ) { |
|
| 121 | - $classnames = [ $classnames ]; |
|
| 120 | + if ( ! is_array($classnames)) { |
|
| 121 | + $classnames = [$classnames]; |
|
| 122 | 122 | } |
| 123 | 123 | |
| 124 | - if ( $tag->hasAttribute( 'class' ) ) { |
|
| 125 | - $tag_classes = array_flip( explode( ' ', $tag->getAttribute( 'class' ) ) ); |
|
| 124 | + if ($tag->hasAttribute('class')) { |
|
| 125 | + $tag_classes = array_flip(explode(' ', $tag->getAttribute('class'))); |
|
| 126 | 126 | |
| 127 | - foreach ( $classnames as $classname ) { |
|
| 128 | - if ( isset( $tag_classes[ $classname ] ) ) { |
|
| 127 | + foreach ($classnames as $classname) { |
|
| 128 | + if (isset($tag_classes[$classname])) { |
|
| 129 | 129 | return true; |
| 130 | 130 | } |
| 131 | 131 | } |
@@ -141,8 +141,8 @@ discard block |
||
| 141 | 141 | * |
| 142 | 142 | * @return string A single character (or the empty string). |
| 143 | 143 | */ |
| 144 | - public static function get_prev_chr( \DOMNode $element ) { |
|
| 145 | - return self::get_adjacent_chr( $element, -1, 1, [ __CLASS__, 'get_previous_textnode' ] ); |
|
| 144 | + public static function get_prev_chr(\DOMNode $element) { |
|
| 145 | + return self::get_adjacent_chr($element, -1, 1, [__CLASS__, 'get_previous_textnode']); |
|
| 146 | 146 | } |
| 147 | 147 | |
| 148 | 148 | /** |
@@ -152,8 +152,8 @@ discard block |
||
| 152 | 152 | * |
| 153 | 153 | * @return string A single character (or the empty string). |
| 154 | 154 | */ |
| 155 | - public static function get_next_chr( \DOMNode $element ) { |
|
| 156 | - return self::get_adjacent_chr( $element, 0, 1, [ __CLASS__, 'get_next_textnode' ] ); |
|
| 155 | + public static function get_next_chr(\DOMNode $element) { |
|
| 156 | + return self::get_adjacent_chr($element, 0, 1, [__CLASS__, 'get_next_textnode']); |
|
| 157 | 157 | } |
| 158 | 158 | |
| 159 | 159 | /** |
@@ -166,15 +166,15 @@ discard block |
||
| 166 | 166 | * |
| 167 | 167 | * @return string The character or an empty string. |
| 168 | 168 | */ |
| 169 | - private static function get_adjacent_chr( \DOMNode $node, $position, $length, callable $get_textnode ) { |
|
| 170 | - $textnode = $get_textnode( $node ); |
|
| 169 | + private static function get_adjacent_chr(\DOMNode $node, $position, $length, callable $get_textnode) { |
|
| 170 | + $textnode = $get_textnode($node); |
|
| 171 | 171 | |
| 172 | - if ( isset( $textnode ) && isset( $textnode->data ) ) { |
|
| 172 | + if (isset($textnode) && isset($textnode->data)) { |
|
| 173 | 173 | // Determine encoding. |
| 174 | - $func = Strings::functions( $textnode->data ); |
|
| 174 | + $func = Strings::functions($textnode->data); |
|
| 175 | 175 | |
| 176 | - if ( ! empty( $func ) ) { |
|
| 177 | - return preg_replace( '/\p{C}/Su', '', $func['substr']( $textnode->data, $position, $length ) ); |
|
| 176 | + if ( ! empty($func)) { |
|
| 177 | + return preg_replace('/\p{C}/Su', '', $func['substr']($textnode->data, $position, $length)); |
|
| 178 | 178 | } |
| 179 | 179 | } |
| 180 | 180 | |
@@ -188,11 +188,11 @@ discard block |
||
| 188 | 188 | * |
| 189 | 189 | * @return \DOMText|null Null if $element is a block-level element or no text sibling exists. |
| 190 | 190 | */ |
| 191 | - public static function get_previous_textnode( \DOMNode $element = null ) { |
|
| 192 | - return self::get_adjacent_textnode( function( &$node = null ) { |
|
| 191 | + public static function get_previous_textnode(\DOMNode $element = null) { |
|
| 192 | + return self::get_adjacent_textnode(function(&$node = null) { |
|
| 193 | 193 | $node = $node->previousSibling; |
| 194 | - return self::get_last_textnode( $node ); |
|
| 195 | - }, __METHOD__, $element ); |
|
| 194 | + return self::get_last_textnode($node); |
|
| 195 | + }, __METHOD__, $element); |
|
| 196 | 196 | } |
| 197 | 197 | |
| 198 | 198 | /** |
@@ -202,11 +202,11 @@ discard block |
||
| 202 | 202 | * |
| 203 | 203 | * @return \DOMText|null Null if $element is a block-level element or no text sibling exists. |
| 204 | 204 | */ |
| 205 | - public static function get_next_textnode( \DOMNode $element = null ) { |
|
| 206 | - return self::get_adjacent_textnode( function( &$node = null ) { |
|
| 205 | + public static function get_next_textnode(\DOMNode $element = null) { |
|
| 206 | + return self::get_adjacent_textnode(function(&$node = null) { |
|
| 207 | 207 | $node = $node->nextSibling; |
| 208 | - return self::get_first_textnode( $node ); |
|
| 209 | - }, __METHOD__, $element ); |
|
| 208 | + return self::get_first_textnode($node); |
|
| 209 | + }, __METHOD__, $element); |
|
| 210 | 210 | } |
| 211 | 211 | |
| 212 | 212 | /** |
@@ -218,22 +218,22 @@ discard block |
||
| 218 | 218 | * |
| 219 | 219 | * @return \DOMText|null Null if $element is a block-level element or no text sibling exists. |
| 220 | 220 | */ |
| 221 | - private static function get_adjacent_textnode( callable $iterate, callable $get_adjacent_parent, \DOMNode $element = null ) { |
|
| 222 | - if ( ! isset( $element ) ) { |
|
| 221 | + private static function get_adjacent_textnode(callable $iterate, callable $get_adjacent_parent, \DOMNode $element = null) { |
|
| 222 | + if ( ! isset($element)) { |
|
| 223 | 223 | return null; |
| 224 | - } elseif ( $element instanceof \DOMElement && isset( self::$block_tags[ $element->tagName ] ) ) { |
|
| 224 | + } elseif ($element instanceof \DOMElement && isset(self::$block_tags[$element->tagName])) { |
|
| 225 | 225 | return null; |
| 226 | 226 | } |
| 227 | 227 | |
| 228 | 228 | $adjacent = null; |
| 229 | 229 | $node = $element; |
| 230 | 230 | |
| 231 | - while ( ! empty( $node ) && empty( $adjacent ) ) { |
|
| 232 | - $adjacent = $iterate( $node ); |
|
| 231 | + while ( ! empty($node) && empty($adjacent)) { |
|
| 232 | + $adjacent = $iterate($node); |
|
| 233 | 233 | } |
| 234 | 234 | |
| 235 | - if ( empty( $adjacent ) ) { |
|
| 236 | - $adjacent = $get_adjacent_parent( $element->parentNode ); |
|
| 235 | + if (empty($adjacent)) { |
|
| 236 | + $adjacent = $get_adjacent_parent($element->parentNode); |
|
| 237 | 237 | } |
| 238 | 238 | |
| 239 | 239 | return $adjacent; |
@@ -247,15 +247,15 @@ discard block |
||
| 247 | 247 | * |
| 248 | 248 | * @return \DOMText|null The first child of type \DOMText, the element itself if it is of type \DOMText or null. |
| 249 | 249 | */ |
| 250 | - public static function get_first_textnode( \DOMNode $element = null, $recursive = false ) { |
|
| 251 | - return self::get_edge_textnode( function( \DOMNodeList $children, \DOMText &$first_textnode = null ) { |
|
| 250 | + public static function get_first_textnode(\DOMNode $element = null, $recursive = false) { |
|
| 251 | + return self::get_edge_textnode(function(\DOMNodeList $children, \DOMText & $first_textnode = null) { |
|
| 252 | 252 | $i = 0; |
| 253 | 253 | |
| 254 | - while ( $i < $children->length && empty( $first_textnode ) ) { |
|
| 255 | - $first_textnode = self::get_first_textnode( $children->item( $i ), true ); |
|
| 254 | + while ($i < $children->length && empty($first_textnode)) { |
|
| 255 | + $first_textnode = self::get_first_textnode($children->item($i), true); |
|
| 256 | 256 | $i++; |
| 257 | 257 | } |
| 258 | - }, $element, $recursive ); |
|
| 258 | + }, $element, $recursive); |
|
| 259 | 259 | } |
| 260 | 260 | |
| 261 | 261 | /** |
@@ -266,15 +266,15 @@ discard block |
||
| 266 | 266 | * |
| 267 | 267 | * @return \DOMText|null The last child of type \DOMText, the element itself if it is of type \DOMText or null. |
| 268 | 268 | */ |
| 269 | - public static function get_last_textnode( \DOMNode $element = null, $recursive = false ) { |
|
| 270 | - return self::get_edge_textnode( function( \DOMNodeList $children, \DOMText &$last_textnode = null ) { |
|
| 269 | + public static function get_last_textnode(\DOMNode $element = null, $recursive = false) { |
|
| 270 | + return self::get_edge_textnode(function(\DOMNodeList $children, \DOMText & $last_textnode = null) { |
|
| 271 | 271 | $i = $children->length - 1; |
| 272 | 272 | |
| 273 | - while ( $i >= 0 && empty( $last_textnode ) ) { |
|
| 274 | - $last_textnode = self::get_last_textnode( $children->item( $i ), true ); |
|
| 273 | + while ($i >= 0 && empty($last_textnode)) { |
|
| 274 | + $last_textnode = self::get_last_textnode($children->item($i), true); |
|
| 275 | 275 | $i--; |
| 276 | 276 | } |
| 277 | - }, $element, $recursive ); |
|
| 277 | + }, $element, $recursive); |
|
| 278 | 278 | } |
| 279 | 279 | |
| 280 | 280 | /** |
@@ -288,24 +288,24 @@ discard block |
||
| 288 | 288 | * |
| 289 | 289 | * @return \DOMText|null The last child of type \DOMText, the element itself if it is of type \DOMText or null. |
| 290 | 290 | */ |
| 291 | - private static function get_edge_textnode( callable $iteration, \DOMNode $element = null, $recursive = false ) { |
|
| 292 | - if ( ! isset( $element ) ) { |
|
| 291 | + private static function get_edge_textnode(callable $iteration, \DOMNode $element = null, $recursive = false) { |
|
| 292 | + if ( ! isset($element)) { |
|
| 293 | 293 | return null; |
| 294 | 294 | } |
| 295 | 295 | |
| 296 | - if ( $element instanceof \DOMText ) { |
|
| 296 | + if ($element instanceof \DOMText) { |
|
| 297 | 297 | return $element; |
| 298 | - } elseif ( ! $element instanceof \DOMElement ) { |
|
| 298 | + } elseif ( ! $element instanceof \DOMElement) { |
|
| 299 | 299 | // Return null if $element is neither \DOMText nor \DOMElement. |
| 300 | 300 | return null; |
| 301 | - } elseif ( $recursive && isset( self::$block_tags[ $element->tagName ] ) ) { |
|
| 301 | + } elseif ($recursive && isset(self::$block_tags[$element->tagName])) { |
|
| 302 | 302 | return null; |
| 303 | 303 | } |
| 304 | 304 | |
| 305 | 305 | $edge_textnode = null; |
| 306 | 306 | |
| 307 | - if ( $element->hasChildNodes() ) { |
|
| 308 | - $iteration( $element->childNodes, $edge_textnode ); |
|
| 307 | + if ($element->hasChildNodes()) { |
|
| 308 | + $iteration($element->childNodes, $edge_textnode); |
|
| 309 | 309 | } |
| 310 | 310 | |
| 311 | 311 | return $edge_textnode; |
@@ -318,13 +318,13 @@ discard block |
||
| 318 | 318 | * |
| 319 | 319 | * @return \DOMElement|null |
| 320 | 320 | */ |
| 321 | - public static function get_block_parent( \DOMNode $element ) { |
|
| 321 | + public static function get_block_parent(\DOMNode $element) { |
|
| 322 | 322 | $parent = $element->parentNode; |
| 323 | - if ( ! $parent instanceof \DOMElement ) { |
|
| 323 | + if ( ! $parent instanceof \DOMElement) { |
|
| 324 | 324 | return null; |
| 325 | 325 | } |
| 326 | 326 | |
| 327 | - while ( ! isset( self::$block_tags[ $parent->tagName ] ) && ! empty( $parent->parentNode ) && $parent->parentNode instanceof \DOMElement ) { |
|
| 327 | + while ( ! isset(self::$block_tags[$parent->tagName]) && ! empty($parent->parentNode) && $parent->parentNode instanceof \DOMElement) { |
|
| 328 | 328 | $parent = $parent->parentNode; |
| 329 | 329 | } |
| 330 | 330 | |
@@ -338,10 +338,10 @@ discard block |
||
| 338 | 338 | |
| 339 | 339 | * @return string The tag name (or the empty string). |
| 340 | 340 | */ |
| 341 | - public static function get_block_parent_name( \DOMNode $element ) { |
|
| 342 | - $parent = self::get_block_parent( $element ); |
|
| 341 | + public static function get_block_parent_name(\DOMNode $element) { |
|
| 342 | + $parent = self::get_block_parent($element); |
|
| 343 | 343 | |
| 344 | - if ( ! empty( $parent ) ) { |
|
| 344 | + if ( ! empty($parent)) { |
|
| 345 | 345 | return $parent->tagName; |
| 346 | 346 | } else { |
| 347 | 347 | return ''; |
@@ -299,28 +299,28 @@ discard block |
||
| 299 | 299 | * |
| 300 | 300 | * @return bool Returns `true` on successful completion, `false` otherwise. |
| 301 | 301 | */ |
| 302 | - public function load( $raw_text ) { |
|
| 303 | - if ( ! is_string( $raw_text ) ) { |
|
| 302 | + public function load($raw_text) { |
|
| 303 | + if ( ! is_string($raw_text)) { |
|
| 304 | 304 | return false; // we have an error, abort. |
| 305 | 305 | } |
| 306 | 306 | |
| 307 | 307 | // Abort if a simple string exceeds 500 characters (security concern). |
| 308 | - if ( preg_match( self::_RE_MAX_STRING_LENGTH, $raw_text ) ) { |
|
| 308 | + if (preg_match(self::_RE_MAX_STRING_LENGTH, $raw_text)) { |
|
| 309 | 309 | return false; |
| 310 | 310 | } |
| 311 | 311 | |
| 312 | 312 | // Detect encoding. |
| 313 | - $str_functions = Strings::functions( $raw_text ); |
|
| 314 | - if ( empty( $str_functions ) ) { |
|
| 313 | + $str_functions = Strings::functions($raw_text); |
|
| 314 | + if (empty($str_functions)) { |
|
| 315 | 315 | return false; // unknown encoding. |
| 316 | 316 | } |
| 317 | 317 | $this->current_strtoupper = $str_functions['strtoupper']; |
| 318 | 318 | |
| 319 | 319 | // Tokenize the raw text parts. |
| 320 | - $this->text = self::tokenize( preg_split( self::_RE_ANY_TEXT, $raw_text, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY ) ); |
|
| 320 | + $this->text = self::tokenize(preg_split(self::_RE_ANY_TEXT, $raw_text, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY)); |
|
| 321 | 321 | |
| 322 | 322 | // The token array should never be empty. |
| 323 | - return ! empty( $this->text ); |
|
| 323 | + return ! empty($this->text); |
|
| 324 | 324 | } |
| 325 | 325 | |
| 326 | 326 | /** |
@@ -334,23 +334,23 @@ discard block |
||
| 334 | 334 | * @type Token $index A token may combine several input parts. |
| 335 | 335 | * } |
| 336 | 336 | */ |
| 337 | - protected static function tokenize( array $parts ) { |
|
| 337 | + protected static function tokenize(array $parts) { |
|
| 338 | 338 | $tokens = []; |
| 339 | 339 | $index = 0; |
| 340 | 340 | |
| 341 | - foreach ( $parts as $part ) { |
|
| 342 | - if ( preg_match( self::_RE_SPACE, $part ) ) { |
|
| 343 | - $tokens[ $index ] = new Token( $part, Token::SPACE ); |
|
| 344 | - } elseif ( preg_match( self::_RE_PUNCTUATION, $part ) ) { |
|
| 345 | - $tokens[ $index ] = new Token( $part, Token::PUNCTUATION ); |
|
| 346 | - } elseif ( preg_match( self::_RE_WORD, $part ) ) { |
|
| 341 | + foreach ($parts as $part) { |
|
| 342 | + if (preg_match(self::_RE_SPACE, $part)) { |
|
| 343 | + $tokens[$index] = new Token($part, Token::SPACE); |
|
| 344 | + } elseif (preg_match(self::_RE_PUNCTUATION, $part)) { |
|
| 345 | + $tokens[$index] = new Token($part, Token::PUNCTUATION); |
|
| 346 | + } elseif (preg_match(self::_RE_WORD, $part)) { |
|
| 347 | 347 | // Make sure that things like email addresses and URLs are not broken up |
| 348 | 348 | // into words and punctuation not preceeded by an 'other'. |
| 349 | - self::parse_ambiguous_token( Token::WORD, $part, $tokens, $index ); |
|
| 349 | + self::parse_ambiguous_token(Token::WORD, $part, $tokens, $index); |
|
| 350 | 350 | } else { |
| 351 | 351 | // Make sure that things like email addresses and URLs are not broken up into words |
| 352 | 352 | // and punctuation not preceeded by an 'other' or 'word'. |
| 353 | - self::parse_ambiguous_token( Token::OTHER, $part, $tokens, $index ); |
|
| 353 | + self::parse_ambiguous_token(Token::OTHER, $part, $tokens, $index); |
|
| 354 | 354 | } |
| 355 | 355 | |
| 356 | 356 | $index++; |
@@ -367,25 +367,25 @@ discard block |
||
| 367 | 367 | * @param array $tokens The token array. Passed by reference. |
| 368 | 368 | * @param int $index The current index. Passed by reference. |
| 369 | 369 | */ |
| 370 | - protected static function parse_ambiguous_token( $expected_type, $part, array &$tokens, &$index ) { |
|
| 370 | + protected static function parse_ambiguous_token($expected_type, $part, array &$tokens, &$index) { |
|
| 371 | 371 | |
| 372 | 372 | // Make sure that things like email addresses and URLs are not broken up incorrectly. |
| 373 | - if ( self::is_preceeded_by( Token::OTHER, $tokens, $index ) || ( Token::OTHER === $expected_type && self::is_preceeded_by( Token::WORD, $tokens, $index ) ) ) { |
|
| 373 | + if (self::is_preceeded_by(Token::OTHER, $tokens, $index) || (Token::OTHER === $expected_type && self::is_preceeded_by(Token::WORD, $tokens, $index))) { |
|
| 374 | 374 | $index--; |
| 375 | - $old_part = $tokens[ $index ]->value; |
|
| 376 | - $tokens[ $index ] = new Token( $old_part . $part, Token::OTHER ); |
|
| 375 | + $old_part = $tokens[$index]->value; |
|
| 376 | + $tokens[$index] = new Token($old_part . $part, Token::OTHER); |
|
| 377 | 377 | |
| 378 | 378 | // Not preceeded by a non-space + punctuation. |
| 379 | - } elseif ( self::is_preceeded_by( Token::PUNCTUATION, $tokens, $index ) && self::is_not_preceeded_by( Token::SPACE, $tokens, $index, 2 ) ) { |
|
| 380 | - $old_part = $tokens[ $index - 1 ]->value; |
|
| 381 | - $older_part = $tokens[ $index - 2 ]->value; |
|
| 382 | - $tokens[ $index - 2 ] = new Token( $older_part . $old_part . $part, Token::OTHER ); |
|
| 383 | - unset( $tokens[ $index - 1 ] ); |
|
| 379 | + } elseif (self::is_preceeded_by(Token::PUNCTUATION, $tokens, $index) && self::is_not_preceeded_by(Token::SPACE, $tokens, $index, 2)) { |
|
| 380 | + $old_part = $tokens[$index - 1]->value; |
|
| 381 | + $older_part = $tokens[$index - 2]->value; |
|
| 382 | + $tokens[$index - 2] = new Token($older_part . $old_part . $part, Token::OTHER); |
|
| 383 | + unset($tokens[$index - 1]); |
|
| 384 | 384 | $index = $index - 2; |
| 385 | 385 | |
| 386 | 386 | // All good. |
| 387 | 387 | } else { |
| 388 | - $tokens[ $index ] = new Token( $part, $expected_type ); |
|
| 388 | + $tokens[$index] = new Token($part, $expected_type); |
|
| 389 | 389 | } |
| 390 | 390 | } |
| 391 | 391 | |
@@ -399,8 +399,8 @@ discard block |
||
| 399 | 399 | * |
| 400 | 400 | * @return bool |
| 401 | 401 | */ |
| 402 | - protected static function is_preceeded_by( $type, array $tokens, $index, $steps = 1 ) { |
|
| 403 | - return $index - $steps >= 0 && $type === $tokens[ $index - $steps ]->type; |
|
| 402 | + protected static function is_preceeded_by($type, array $tokens, $index, $steps = 1) { |
|
| 403 | + return $index - $steps >= 0 && $type === $tokens[$index - $steps]->type; |
|
| 404 | 404 | } |
| 405 | 405 | |
| 406 | 406 | /** |
@@ -413,8 +413,8 @@ discard block |
||
| 413 | 413 | * |
| 414 | 414 | * @return bool |
| 415 | 415 | */ |
| 416 | - protected static function is_not_preceeded_by( $type, array $tokens, $index, $steps = 1 ) { |
|
| 417 | - return $index - $steps >= 0 && $type !== $tokens[ $index - $steps ]->type; |
|
| 416 | + protected static function is_not_preceeded_by($type, array $tokens, $index, $steps = 1) { |
|
| 417 | + return $index - $steps >= 0 && $type !== $tokens[$index - $steps]->type; |
|
| 418 | 418 | } |
| 419 | 419 | |
| 420 | 420 | |
@@ -426,7 +426,7 @@ discard block |
||
| 426 | 426 | * @return bool Returns true on successful completion. |
| 427 | 427 | */ |
| 428 | 428 | public function reload() { |
| 429 | - return $this->load( $this->unload() ); |
|
| 429 | + return $this->load($this->unload()); |
|
| 430 | 430 | } |
| 431 | 431 | |
| 432 | 432 | /** |
@@ -437,7 +437,7 @@ discard block |
||
| 437 | 437 | public function unload() { |
| 438 | 438 | $reassembled_text = ''; |
| 439 | 439 | |
| 440 | - foreach ( $this->text as $token ) { |
|
| 440 | + foreach ($this->text as $token) { |
|
| 441 | 441 | $reassembled_text .= $token->value; |
| 442 | 442 | } |
| 443 | 443 | |
@@ -463,9 +463,9 @@ discard block |
||
| 463 | 463 | * @type Text_Parser\Token $index |
| 464 | 464 | * } |
| 465 | 465 | */ |
| 466 | - public function update( $tokens ) { |
|
| 467 | - foreach ( $tokens as $index => $token ) { |
|
| 468 | - $this->text[ $index ] = $this->text[ $index ]->with_value( $token->value ); |
|
| 466 | + public function update($tokens) { |
|
| 467 | + foreach ($tokens as $index => $token) { |
|
| 468 | + $this->text[$index] = $this->text[$index]->with_value($token->value); |
|
| 469 | 469 | } |
| 470 | 470 | } |
| 471 | 471 | |
@@ -484,7 +484,7 @@ discard block |
||
| 484 | 484 | * @return array An array of Text_Parser\Token. |
| 485 | 485 | */ |
| 486 | 486 | public function get_spaces() { |
| 487 | - return $this->get_type( Token::SPACE ); |
|
| 487 | + return $this->get_type(Token::SPACE); |
|
| 488 | 488 | } |
| 489 | 489 | |
| 490 | 490 | /** |
@@ -493,7 +493,7 @@ discard block |
||
| 493 | 493 | * @return array An array of Text_Parser\Token. |
| 494 | 494 | */ |
| 495 | 495 | public function get_punctuation() { |
| 496 | - return $this->get_type( Token::PUNCTUATION ); |
|
| 496 | + return $this->get_type(Token::PUNCTUATION); |
|
| 497 | 497 | } |
| 498 | 498 | |
| 499 | 499 | /** |
@@ -505,22 +505,22 @@ discard block |
||
| 505 | 505 | * |
| 506 | 506 | * @return array An array of Text_Parser\Token. |
| 507 | 507 | */ |
| 508 | - public function get_words( $abc = self::ALLOW_ALL_LETTERS, $caps = self::ALLOW_ALL_CAPS, $comps = self::ALLOW_COMPOUNDS ) { |
|
| 508 | + public function get_words($abc = self::ALLOW_ALL_LETTERS, $caps = self::ALLOW_ALL_CAPS, $comps = self::ALLOW_COMPOUNDS) { |
|
| 509 | 509 | // Return early if no text has been loaded. |
| 510 | - if ( ! isset( $this->text ) || ! is_callable( $this->current_strtoupper ) ) { |
|
| 510 | + if ( ! isset($this->text) || ! is_callable($this->current_strtoupper)) { |
|
| 511 | 511 | return []; // abort. |
| 512 | 512 | } |
| 513 | 513 | |
| 514 | 514 | // Result set. |
| 515 | 515 | $tokens = []; |
| 516 | 516 | |
| 517 | - foreach ( $this->get_type( Token::WORD ) as $index => $token ) { |
|
| 517 | + foreach ($this->get_type(Token::WORD) as $index => $token) { |
|
| 518 | 518 | |
| 519 | - if ( $this->conforms_to_letters_policy( $token, $abc ) && |
|
| 520 | - $this->conforms_to_caps_policy( $token, $caps ) && |
|
| 521 | - $this->conforms_to_compounds_policy( $token, $comps ) ) { |
|
| 519 | + if ($this->conforms_to_letters_policy($token, $abc) && |
|
| 520 | + $this->conforms_to_caps_policy($token, $caps) && |
|
| 521 | + $this->conforms_to_compounds_policy($token, $comps)) { |
|
| 522 | 522 | |
| 523 | - $tokens[ $index ] = $token; |
|
| 523 | + $tokens[$index] = $token; |
|
| 524 | 524 | } |
| 525 | 525 | } |
| 526 | 526 | |
@@ -535,18 +535,18 @@ discard block |
||
| 535 | 535 | * |
| 536 | 536 | * @return bool |
| 537 | 537 | */ |
| 538 | - protected function conforms_to_letters_policy( Token $token, $policy ) { |
|
| 538 | + protected function conforms_to_letters_policy(Token $token, $policy) { |
|
| 539 | 539 | |
| 540 | 540 | // Short circuit. |
| 541 | - if ( self::ALLOW_ALL_LETTERS === $policy ) { |
|
| 541 | + if (self::ALLOW_ALL_LETTERS === $policy) { |
|
| 542 | 542 | return true; |
| 543 | 543 | } |
| 544 | 544 | |
| 545 | - $lettered = preg_replace( self::_RE_HTML_LETTER_CONNECTORS, '', $token->value ); |
|
| 545 | + $lettered = preg_replace(self::_RE_HTML_LETTER_CONNECTORS, '', $token->value); |
|
| 546 | 546 | |
| 547 | 547 | return |
| 548 | - ( self::REQUIRE_ALL_LETTERS === $policy && $lettered === $token->value ) || |
|
| 549 | - ( self::NO_ALL_LETTERS === $policy && $lettered !== $token->value ); |
|
| 548 | + (self::REQUIRE_ALL_LETTERS === $policy && $lettered === $token->value) || |
|
| 549 | + (self::NO_ALL_LETTERS === $policy && $lettered !== $token->value); |
|
| 550 | 550 | } |
| 551 | 551 | |
| 552 | 552 | /** |
@@ -557,19 +557,19 @@ discard block |
||
| 557 | 557 | * |
| 558 | 558 | * @return bool |
| 559 | 559 | */ |
| 560 | - protected function conforms_to_caps_policy( Token $token, $policy ) { |
|
| 560 | + protected function conforms_to_caps_policy(Token $token, $policy) { |
|
| 561 | 561 | |
| 562 | 562 | // Short circuit. |
| 563 | - if ( self::ALLOW_ALL_CAPS === $policy ) { |
|
| 563 | + if (self::ALLOW_ALL_CAPS === $policy) { |
|
| 564 | 564 | return true; |
| 565 | 565 | } |
| 566 | 566 | |
| 567 | 567 | // Token value in all-caps. |
| 568 | - $capped = call_user_func( $this->current_strtoupper, $token->value ); |
|
| 568 | + $capped = call_user_func($this->current_strtoupper, $token->value); |
|
| 569 | 569 | |
| 570 | 570 | return |
| 571 | - ( self::REQUIRE_ALL_CAPS === $policy && $capped === $token->value ) || |
|
| 572 | - ( self::NO_ALL_CAPS === $policy && $capped !== $token->value ); |
|
| 571 | + (self::REQUIRE_ALL_CAPS === $policy && $capped === $token->value) || |
|
| 572 | + (self::NO_ALL_CAPS === $policy && $capped !== $token->value); |
|
| 573 | 573 | } |
| 574 | 574 | |
| 575 | 575 | /** |
@@ -580,18 +580,18 @@ discard block |
||
| 580 | 580 | * |
| 581 | 581 | * @return bool |
| 582 | 582 | */ |
| 583 | - protected function conforms_to_compounds_policy( Token $token, $policy ) { |
|
| 583 | + protected function conforms_to_compounds_policy(Token $token, $policy) { |
|
| 584 | 584 | |
| 585 | 585 | // Short circuit. |
| 586 | - if ( self::ALLOW_COMPOUNDS === $policy ) { |
|
| 586 | + if (self::ALLOW_COMPOUNDS === $policy) { |
|
| 587 | 587 | return true; |
| 588 | 588 | } |
| 589 | 589 | |
| 590 | - $uncompound = preg_replace( '/-/S', '', $token->value ); |
|
| 590 | + $uncompound = preg_replace('/-/S', '', $token->value); |
|
| 591 | 591 | |
| 592 | 592 | return |
| 593 | - ( self::REQUIRE_COMPOUNDS === $policy && $uncompound !== $token->value ) || |
|
| 594 | - ( self::NO_COMPOUNDS === $policy && $uncompound === $token->value ); |
|
| 593 | + (self::REQUIRE_COMPOUNDS === $policy && $uncompound !== $token->value) || |
|
| 594 | + (self::NO_COMPOUNDS === $policy && $uncompound === $token->value); |
|
| 595 | 595 | } |
| 596 | 596 | |
| 597 | 597 | /** |
@@ -600,7 +600,7 @@ discard block |
||
| 600 | 600 | * @return array An array of Text_Parser\Token. |
| 601 | 601 | */ |
| 602 | 602 | public function get_other() { |
| 603 | - return $this->get_type( Token::OTHER ); |
|
| 603 | + return $this->get_type(Token::OTHER); |
|
| 604 | 604 | } |
| 605 | 605 | |
| 606 | 606 | /** |
@@ -610,12 +610,12 @@ discard block |
||
| 610 | 610 | * |
| 611 | 611 | * @return array An array of Text_Parser\Token. |
| 612 | 612 | */ |
| 613 | - public function get_type( $type ) { |
|
| 613 | + public function get_type($type) { |
|
| 614 | 614 | $tokens = []; |
| 615 | 615 | |
| 616 | - foreach ( $this->text as $index => $token ) { |
|
| 617 | - if ( $token->type === $type ) { |
|
| 618 | - $tokens[ $index ] = $token; |
|
| 616 | + foreach ($this->text as $index => $token) { |
|
| 617 | + if ($token->type === $type) { |
|
| 618 | + $tokens[$index] = $token; |
|
| 619 | 619 | } |
| 620 | 620 | } |
| 621 | 621 | |
@@ -103,23 +103,23 @@ discard block |
||
| 103 | 103 | * |
| 104 | 104 | * @return string A list of top-level domains concatenated with '|'. |
| 105 | 105 | */ |
| 106 | - private static function get_top_level_domains_from_file( $path ) { |
|
| 106 | + private static function get_top_level_domains_from_file($path) { |
|
| 107 | 107 | $domains = []; |
| 108 | 108 | |
| 109 | - if ( file_exists( $path ) ) { |
|
| 110 | - $file = new \SplFileObject( $path ); |
|
| 109 | + if (file_exists($path)) { |
|
| 110 | + $file = new \SplFileObject($path); |
|
| 111 | 111 | |
| 112 | - while ( ! $file->eof() ) { |
|
| 112 | + while ( ! $file->eof()) { |
|
| 113 | 113 | $line = $file->fgets(); |
| 114 | 114 | |
| 115 | - if ( preg_match( '#^[a-zA-Z0-9][a-zA-Z0-9-]*$#', $line, $matches ) ) { |
|
| 116 | - $domains[] = strtolower( $matches[0] ); |
|
| 115 | + if (preg_match('#^[a-zA-Z0-9][a-zA-Z0-9-]*$#', $line, $matches)) { |
|
| 116 | + $domains[] = strtolower($matches[0]); |
|
| 117 | 117 | } |
| 118 | 118 | } |
| 119 | 119 | } |
| 120 | 120 | |
| 121 | - if ( count( $domains ) > 0 ) { |
|
| 122 | - return implode( '|', $domains ); |
|
| 121 | + if (count($domains) > 0) { |
|
| 122 | + return implode('|', $domains); |
|
| 123 | 123 | } else { |
| 124 | 124 | return 'ac|ad|aero|ae|af|ag|ai|al|am|an|ao|aq|arpa|ar|asia|as|at|au|aw|ax|az|ba|bb|bd|be|bf|bg|bh|biz|bi|bj|bm|bn|bo|br|bs|bt|bv|bw|by|bz|cat|ca|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|com|coop|co|cr|cu|cv|cx|cy|cz|de|dj|dk|dm|do|dz|ec|edu|ee|eg|er|es|et|eu|fi|fj|fk|fm|fo|fr|ga|gb|gd|ge|gf|gg|gh|gi|gl|gm|gn|gov|gp|gq|gr|gs|gt|gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie|il|im|info|int|in|io|iq|ir|is|it|je|jm|jobs|jo|jp|ke|kg|kh|ki|km|kn|kp|kr|kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|ma|mc|md|me|mg|mh|mil|mk|ml|mm|mn|mobi|mo|mp|mq|mr|ms|mt|museum|mu|mv|mw|mx|my|mz|name|na|nc|net|ne|nf|ng|ni|nl|no|np|nr|nu|nz|om|org|pa|pe|pf|pg|ph|pk|pl|pm|pn|pro|pr|ps|pt|pw|py|qa|re|ro|rs|ru|rw|sa|sb|sc|sd|se|sg|sh|si|sj|sk|sl|sm|sn|so|sr|st|su|sv|sy|sz|tc|td|tel|tf|tg|th|tj|tk|tl|tm|tn|to|tp|travel|tr|tt|tv|tw|tz|ua|ug|uk|um|us|uy|uz|va|vc|ve|vg|vi|vn|vu|wf|ws|ye|yt|yu|za|zm|zw'; |
| 125 | 125 | } |
@@ -131,9 +131,9 @@ discard block |
||
| 131 | 131 | * @return string |
| 132 | 132 | */ |
| 133 | 133 | public static function top_level_domains() { |
| 134 | - if ( empty( self::$top_level_domains_pattern ) ) { |
|
| 134 | + if (empty(self::$top_level_domains_pattern)) { |
|
| 135 | 135 | // Initialize valid top level domains from IANA list. |
| 136 | - self::$top_level_domains_pattern = self::get_top_level_domains_from_file( __DIR__ . '/IANA/tlds-alpha-by-domain.txt' ); |
|
| 136 | + self::$top_level_domains_pattern = self::get_top_level_domains_from_file(__DIR__ . '/IANA/tlds-alpha-by-domain.txt'); |
|
| 137 | 137 | } |
| 138 | 138 | |
| 139 | 139 | return self::$top_level_domains_pattern; |
@@ -55,7 +55,7 @@ |
||
| 55 | 55 | * @param string $open Opening quote character(s). |
| 56 | 56 | * @param string $close Closing quote character(s). |
| 57 | 57 | */ |
| 58 | - public function __construct( $open, $close ) { |
|
| 58 | + public function __construct($open, $close) { |
|
| 59 | 59 | $this->open = $open; |
| 60 | 60 | $this->close = $close; |
| 61 | 61 | } |