@@ -32,9 +32,9 @@ discard block |
||
| 32 | 32 | */ |
| 33 | 33 | final public function each($func) |
| 34 | 34 | { |
| 35 | - foreach ($this->elements as $inx => $val) |
|
| 35 | + foreach($this->elements as $inx => $val) |
|
| 36 | 36 | { |
| 37 | - call_user_func($func,$inx,$val); |
|
| 37 | + call_user_func($func, $inx, $val); |
|
| 38 | 38 | } |
| 39 | 39 | return $this; |
| 40 | 40 | } |
@@ -46,7 +46,7 @@ discard block |
||
| 46 | 46 | */ |
| 47 | 47 | final public function eq($inx) |
| 48 | 48 | { |
| 49 | - return isset($this->elements[$inx])?$this->elements[$inx]:NULL; |
|
| 49 | + return isset($this->elements[$inx]) ? $this->elements[$inx] : NULL; |
|
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | /** |
@@ -20,7 +20,7 @@ |
||
| 20 | 20 | |
| 21 | 21 | public function __construct() |
| 22 | 22 | { |
| 23 | - $this->context = stream_context_create($this->context_options); |
|
| 23 | + $this->context = stream_context_create($this->context_options); |
|
| 24 | 24 | } |
| 25 | 25 | |
| 26 | 26 | /** |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | * Opcionees del contexto de flujo |
| 17 | 17 | * @var array |
| 18 | 18 | */ |
| 19 | - private $context_options = array('http'=>array('method'=>"GET",'timout'=> 6,'ignore_errors' => true)); |
|
| 19 | + private $context_options = array('http'=>array('method'=>"GET", 'timout'=> 6, 'ignore_errors' => true)); |
|
| 20 | 20 | |
| 21 | 21 | public function __construct() |
| 22 | 22 | { |
@@ -30,13 +30,13 @@ discard block |
||
| 30 | 30 | */ |
| 31 | 31 | final public function import($content) |
| 32 | 32 | { |
| 33 | - if(!!filter_var($content,FILTER_VALIDATE_URL)||!!is_readable($content)) |
|
| 33 | + if(!!filter_var($content, FILTER_VALIDATE_URL) || !!is_readable($content)) |
|
| 34 | 34 | { |
| 35 | - $content = @file_get_contents($content,false,$this->context); |
|
| 35 | + $content = @file_get_contents($content, false, $this->context); |
|
| 36 | 36 | |
| 37 | - return !!$this->isStringHtml($content)?$content:False; |
|
| 37 | + return !!$this->isStringHtml($content) ? $content : False; |
|
| 38 | 38 | } |
| 39 | - return !!$this->isStringHtml($content)?$content:NULL; |
|
| 39 | + return !!$this->isStringHtml($content) ? $content : NULL; |
|
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | /** |
@@ -18,17 +18,17 @@ |
||
| 18 | 18 | */ |
| 19 | 19 | protected $elements = array(); |
| 20 | 20 | |
| 21 | - public function __construct (\DOMNodeList $node_list) |
|
| 21 | + public function __construct(\DOMNodeList $node_list) |
|
| 22 | 22 | { |
| 23 | 23 | $d = new \DOMDocument(); |
| 24 | 24 | |
| 25 | 25 | foreach($node_list as $node) |
| 26 | 26 | { |
| 27 | - if($node->nodeType == 1&&!in_array($node->tagName, ['br','hr'])) |
|
| 27 | + if($node->nodeType == 1 && !in_array($node->tagName, ['br', 'hr'])) |
|
| 28 | 28 | { |
| 29 | 29 | $this->elements[] = new \PHPTools\PHPHtmlDom\Core\PHPHtmlDomElement($node); |
| 30 | 30 | |
| 31 | - $d->appendChild($d->importNode($node->cloneNode(TRUE),TRUE)); |
|
| 31 | + $d->appendChild($d->importNode($node->cloneNode(TRUE), TRUE)); |
|
| 32 | 32 | } |
| 33 | 33 | } |
| 34 | 34 | |
@@ -40,9 +40,9 @@ discard block |
||
| 40 | 40 | * @param array $data arreglo con los parametros necesarios para escribir el log. |
| 41 | 41 | * @return void |
| 42 | 42 | */ |
| 43 | - final public function logError($msg_code,$data = array()) |
|
| 43 | + final public function logError($msg_code, $data = array()) |
|
| 44 | 44 | { |
| 45 | - self::write(self::compileMessage(self::$error_msg[$msg_code],$data), PEL_ERROR); |
|
| 45 | + self::write(self::compileMessage(self::$error_msg[$msg_code], $data), PEL_ERROR); |
|
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | /** |
@@ -51,9 +51,9 @@ discard block |
||
| 51 | 51 | * @param array $data arreglo con los parametros necesarios para escribir el log. |
| 52 | 52 | * @return void |
| 53 | 53 | */ |
| 54 | - final public function logWarn($msg_code,$data = array()) |
|
| 54 | + final public function logWarn($msg_code, $data = array()) |
|
| 55 | 55 | { |
| 56 | - self::write(self::compileMessage(self::$warn_msg[$msg_code],$data), PEL_WARNING); |
|
| 56 | + self::write(self::compileMessage(self::$warn_msg[$msg_code], $data), PEL_WARNING); |
|
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | /** |
@@ -62,9 +62,9 @@ discard block |
||
| 62 | 62 | * @param array $data arreglo con los parametros necesarios para escribir el log. |
| 63 | 63 | * @return void |
| 64 | 64 | */ |
| 65 | - final public function logInfo($msg_code,$data = array()) |
|
| 65 | + final public function logInfo($msg_code, $data = array()) |
|
| 66 | 66 | { |
| 67 | - self::write(self::compileMessage(self::$info_msg[$msg_code],$data), PEL_INFO); |
|
| 67 | + self::write(self::compileMessage(self::$info_msg[$msg_code], $data), PEL_INFO); |
|
| 68 | 68 | } |
| 69 | 69 | |
| 70 | 70 | /** |
@@ -73,8 +73,8 @@ discard block |
||
| 73 | 73 | * @param array $data Arreglo con los parametros del mensaje. |
| 74 | 74 | * @return string |
| 75 | 75 | */ |
| 76 | - private function compileMessage($msg,$data) |
|
| 76 | + private function compileMessage($msg, $data) |
|
| 77 | 77 | { |
| 78 | - return sprintf("PHPHtmlDom: %s",vsprintf($msg,$data)); |
|
| 78 | + return sprintf("PHPHtmlDom: %s", vsprintf($msg, $data)); |
|
| 79 | 79 | } |
| 80 | 80 | } |
| 81 | 81 | \ No newline at end of file |
@@ -78,9 +78,9 @@ |
||
| 78 | 78 | */ |
| 79 | 79 | private function get_childs() |
| 80 | 80 | { |
| 81 | - $this->childs = new \PHPTools\PHPHtmlDom\Core\PHPHtmlDomList($this->dom_element->childNodes); |
|
| 81 | + $this->childs = new \PHPTools\PHPHtmlDom\Core\PHPHtmlDomList($this->dom_element->childNodes); |
|
| 82 | 82 | |
| 83 | - return $this; |
|
| 83 | + return $this; |
|
| 84 | 84 | } |
| 85 | 85 | |
| 86 | 86 | /** |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | */ |
| 43 | 43 | public $childs; |
| 44 | 44 | |
| 45 | - public function __construct (\DOMElement $element) |
|
| 45 | + public function __construct(\DOMElement $element) |
|
| 46 | 46 | { |
| 47 | 47 | $this->dom_element = $element; |
| 48 | 48 | |
@@ -89,20 +89,20 @@ discard block |
||
| 89 | 89 | */ |
| 90 | 90 | private function get_Text() |
| 91 | 91 | { |
| 92 | - $text_formatting = array('b','strong','em','i','small','strong','sub','sup','ins','del','mark','br','hr'); |
|
| 92 | + $text_formatting = array('b', 'strong', 'em', 'i', 'small', 'strong', 'sub', 'sup', 'ins', 'del', 'mark', 'br', 'hr'); |
|
| 93 | 93 | |
| 94 | - foreach ($this->dom_element->childNodes as $node) |
|
| 94 | + foreach($this->dom_element->childNodes as $node) |
|
| 95 | 95 | { |
| 96 | 96 | if($node->nodeType == 3) |
| 97 | 97 | { |
| 98 | 98 | $this->set_text(trim($node->textContent)); |
| 99 | - $this->textFormatting.=$node->textContent; |
|
| 99 | + $this->textFormatting .= $node->textContent; |
|
| 100 | 100 | } |
| 101 | 101 | else if($node->nodeType == 1 && !!in_array($node->tagName, $text_formatting)) |
| 102 | 102 | { |
| 103 | - if(!!in_array($node->tagName, ['br','hr'])) |
|
| 103 | + if(!!in_array($node->tagName, ['br', 'hr'])) |
|
| 104 | 104 | { |
| 105 | - $this->textFormatting.= sprintf('<%s>',$node->tagName); |
|
| 105 | + $this->textFormatting .= sprintf('<%s>', $node->tagName); |
|
| 106 | 106 | } |
| 107 | 107 | else |
| 108 | 108 | { |
@@ -110,7 +110,7 @@ discard block |
||
| 110 | 110 | $attrs = $this->attrs_to_string($node->attributes); |
| 111 | 111 | $text = $node->textContent; |
| 112 | 112 | |
| 113 | - $this->textFormatting.= sprintf('<%1$s%2$s>%3$s</%1$s>',$tag,$attrs,$text); |
|
| 113 | + $this->textFormatting .= sprintf('<%1$s%2$s>%3$s</%1$s>', $tag, $attrs, $text); |
|
| 114 | 114 | } |
| 115 | 115 | } |
| 116 | 116 | } |
@@ -135,7 +135,7 @@ discard block |
||
| 135 | 135 | } |
| 136 | 136 | else |
| 137 | 137 | { |
| 138 | - $this->text = array($this->text,$text); |
|
| 138 | + $this->text = array($this->text, $text); |
|
| 139 | 139 | } |
| 140 | 140 | } |
| 141 | 141 | else |
@@ -154,11 +154,11 @@ discard block |
||
| 154 | 154 | */ |
| 155 | 155 | private function attrs_to_string($attrs) |
| 156 | 156 | { |
| 157 | - $attrs_string =''; |
|
| 157 | + $attrs_string = ''; |
|
| 158 | 158 | |
| 159 | 159 | foreach($attrs as $name => $node) |
| 160 | 160 | { |
| 161 | - $attrs_string.= sprintf(' %s="%s"',$name,$node->nodeValue); |
|
| 161 | + $attrs_string .= sprintf(' %s="%s"', $name, $node->nodeValue); |
|
| 162 | 162 | } |
| 163 | 163 | |
| 164 | 164 | return $attrs_string; |
@@ -13,7 +13,7 @@ discard block |
||
| 13 | 13 | */ |
| 14 | 14 | final public function hasclass($classname) |
| 15 | 15 | { |
| 16 | - return !!$this->hasattr('class')?in_array($classname, explode(' ', $this->attrs->class)):FALSE; |
|
| 16 | + return !!$this->hasattr('class') ? in_array($classname, explode(' ', $this->attrs->class)) : FALSE; |
|
| 17 | 17 | } |
| 18 | 18 | |
| 19 | 19 | /** |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | */ |
| 34 | 34 | final public function attr($inx) |
| 35 | 35 | { |
| 36 | - return !!$this->hasattr($inx)?$this->attrs->{$inx}:NULL; |
|
| 36 | + return !!$this->hasattr($inx) ? $this->attrs->{$inx}:NULL; |
|
| 37 | 37 | } |
| 38 | 38 | |
| 39 | 39 | /** |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | */ |
| 44 | 44 | final public function data($inx) |
| 45 | 45 | { |
| 46 | - return $this->attr(sprintf('data-%s',$inx)); |
|
| 46 | + return $this->attr(sprintf('data-%s', $inx)); |
|
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | /** |
@@ -127,7 +127,7 @@ |
||
| 127 | 127 | { |
| 128 | 128 | $xpath = $this->selector->toXPath($css_selector); |
| 129 | 129 | } |
| 130 | - catch (\Exception $e) |
|
| 130 | + catch(\Exception $e) |
|
| 131 | 131 | { |
| 132 | 132 | $this->logger->logError('E003', array($css_selector)); |
| 133 | 133 | $this->logger->logError('E000', array($e->getMessage())); |