@@ -30,15 +30,18 @@ discard block |
||
| 30 | 30 | } |
| 31 | 31 | |
| 32 | 32 | public function run(\DomElement $element) { |
| 33 | - if ($this->file !== null) $this->filePath->setBaseDir(dirname(realpath($this->file)) . DIRECTORY_SEPARATOR); |
|
| 33 | + if ($this->file !== null) { |
|
| 34 | + $this->filePath->setBaseDir(dirname(realpath($this->file)) . DIRECTORY_SEPARATOR); |
|
| 35 | + } |
|
| 34 | 36 | $this->functionSet->setElement($element); |
| 35 | 37 | $this->configLine = $this->line; |
| 36 | 38 | try { |
| 37 | 39 | //Don't run if there's a pseudo element like nth-child() and this element doesn't match it |
| 38 | - if (!$this->pseudoMatcher->matches($element)) return; |
|
| 40 | + if (!$this->pseudoMatcher->matches($element)) { |
|
| 41 | + return; |
|
| 42 | + } |
|
| 39 | 43 | $this->callProperties($element); |
| 40 | - } |
|
| 41 | - catch (\Transphporm\RunException $e) { |
|
| 44 | + } catch (\Transphporm\RunException $e) { |
|
| 42 | 45 | throw new \Transphporm\Exception($e, $this->file, $this->line); |
| 43 | 46 | } |
| 44 | 47 | } |
@@ -49,7 +52,9 @@ discard block |
||
| 49 | 52 | private function callProperties($element) { |
| 50 | 53 | foreach ($this->rules as $name => $value) { |
| 51 | 54 | $result = $this->callProperty($name, $element, $this->getArgs($value)); |
| 52 | - if ($result === false) break; |
|
| 55 | + if ($result === false) { |
|
| 56 | + break; |
|
| 57 | + } |
|
| 53 | 58 | } |
| 54 | 59 | } |
| 55 | 60 | private function getArgs($value) { |
@@ -64,9 +69,10 @@ discard block |
||
| 64 | 69 | if (isset($this->properties[$name])) { |
| 65 | 70 | try { |
| 66 | 71 | return $this->properties[$name]->run($value, $element, $this->rules, $this->pseudoMatcher, $this->properties); |
| 67 | - } |
|
| 68 | - catch (\Exception $e) { |
|
| 69 | - if ($e instanceof \Transphporm\RunException) throw $e; |
|
| 72 | + } catch (\Exception $e) { |
|
| 73 | + if ($e instanceof \Transphporm\RunException) { |
|
| 74 | + throw $e; |
|
| 75 | + } |
|
| 70 | 76 | throw new \Transphporm\RunException(\Transphporm\Exception::PROPERTY, $name, $e); |
| 71 | 77 | } |
| 72 | 78 | } |