@@ -17,7 +17,9 @@ |
||
| 17 | 17 | |
| 18 | 18 | public static function string(SimpleXMLElement $xml) { |
| 19 | 19 | |
| 20 | - if (false === ($xml = dom_import_simplexml($xml))) return ''; |
|
| 20 | + if (false === ($xml = dom_import_simplexml($xml))) { |
|
| 21 | + return ''; |
|
| 22 | + } |
|
| 21 | 23 | |
| 22 | 24 | $dom = $xml->ownerDocument; $dom->formatOutput = true; |
| 23 | 25 | |
@@ -8,7 +8,7 @@ |
||
| 8 | 8 | |
| 9 | 9 | public static function create(string $data) { |
| 10 | 10 | |
| 11 | - $data = ('<?xml version="1.0" encoding="UTF-8" ?>' . $data); |
|
| 11 | + $data = ('<?xml version="1.0" encoding="UTF-8" ?>'.$data); |
|
| 12 | 12 | |
| 13 | 13 | return @simplexml_load_string($data); |
| 14 | 14 | } |
@@ -45,9 +45,9 @@ |
||
| 45 | 45 | |
| 46 | 46 | if (preg_match(REGEX_FORM_FIELD_KEY, $key)) { |
| 47 | 47 | |
| 48 | - $prefix = (('' !== $this->form->name()) ? ($this->form->name() . '_') : ''); |
|
| 48 | + $prefix = (('' !== $this->form->name()) ? ($this->form->name().'_') : ''); |
|
| 49 | 49 | |
| 50 | - $this->key = $key; $this->name = ($prefix . $key); |
|
| 50 | + $this->key = $key; $this->name = ($prefix.$key); |
|
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | # Set params |
@@ -14,6 +14,9 @@ |
||
| 14 | 14 | |
| 15 | 15 | # Get tag |
| 16 | 16 | |
| 17 | + /** |
|
| 18 | + * @param string $contents |
|
| 19 | + */ |
|
| 17 | 20 | protected function getTag(string $name, array $attributes = [], $contents = null) { |
| 18 | 21 | |
| 19 | 22 | $tag = new Tag($name, $attributes, $contents); |
@@ -2,7 +2,9 @@ |
||
| 2 | 2 | |
| 3 | 3 | namespace Form\Utils { |
| 4 | 4 | |
| 5 | - use Form, Request, Tag; |
|
| 5 | + use Form; |
|
| 6 | + use Request; |
|
| 7 | + use Tag; |
|
| 6 | 8 | |
| 7 | 9 | abstract class Field { |
| 8 | 10 | |
@@ -24,11 +24,17 @@ discard block |
||
| 24 | 24 | |
| 25 | 25 | # Set config |
| 26 | 26 | |
| 27 | - if ($this->disabled) $tag->set('disabled', 'disabled'); |
|
| 27 | + if ($this->disabled) { |
|
| 28 | + $tag->set('disabled', 'disabled'); |
|
| 29 | + } |
|
| 28 | 30 | |
| 29 | - if ($this->required) $tag->set('data-required', 'required'); |
|
| 31 | + if ($this->required) { |
|
| 32 | + $tag->set('data-required', 'required'); |
|
| 33 | + } |
|
| 30 | 34 | |
| 31 | - if ($this->error) $tag->set('data-error', 'error'); |
|
| 35 | + if ($this->error) { |
|
| 36 | + $tag->set('data-error', 'error'); |
|
| 37 | + } |
|
| 32 | 38 | |
| 33 | 39 | # ------------------------ |
| 34 | 40 | |
@@ -54,11 +60,12 @@ discard block |
||
| 54 | 60 | |
| 55 | 61 | $params = array_merge(['disabled' => false, 'required' => false], $this->config); |
| 56 | 62 | |
| 57 | - foreach ($params as $name => $default) if (isset($config[$name])) { |
|
| 63 | + foreach ($params as $name => $default) { |
|
| 64 | + if (isset($config[$name])) { |
|
| 58 | 65 | |
| 59 | - try { $this->$name($config[$name]); } |
|
| 60 | - |
|
| 61 | - catch (\TypeError $e) { /* Ignore setting value of illegal type */ } |
|
| 66 | + try { $this->$name($config[$name]); |
|
| 67 | + } |
|
| 68 | + } catch (\TypeError $e) { /* Ignore setting value of illegal type */ } |
|
| 62 | 69 | } |
| 63 | 70 | } |
| 64 | 71 | |
@@ -66,7 +73,9 @@ discard block |
||
| 66 | 73 | |
| 67 | 74 | public function post() { |
| 68 | 75 | |
| 69 | - if ($this->posted || $this->disabled || ('' === $this->key)) return false; |
|
| 76 | + if ($this->posted || $this->disabled || ('' === $this->key)) { |
|
| 77 | + return false; |
|
| 78 | + } |
|
| 70 | 79 | |
| 71 | 80 | $this->error = (!$this->set(Request::post($this->name)) && $this->required); |
| 72 | 81 | |
@@ -100,7 +109,9 @@ discard block |
||
| 100 | 109 | |
| 101 | 110 | public function disabled(bool $value = null) { |
| 102 | 111 | |
| 103 | - if (null === $value) return $this->disabled; |
|
| 112 | + if (null === $value) { |
|
| 113 | + return $this->disabled; |
|
| 114 | + } |
|
| 104 | 115 | |
| 105 | 116 | $this->disabled = $value; |
| 106 | 117 | } |
@@ -109,7 +120,9 @@ discard block |
||
| 109 | 120 | |
| 110 | 121 | public function required(bool $value = null) { |
| 111 | 122 | |
| 112 | - if (null === $value) return $this->required; |
|
| 123 | + if (null === $value) { |
|
| 124 | + return $this->required; |
|
| 125 | + } |
|
| 113 | 126 | |
| 114 | 127 | $this->required = $value; |
| 115 | 128 | } |
@@ -118,7 +131,9 @@ discard block |
||
| 118 | 131 | |
| 119 | 132 | public function error(bool $value = null) { |
| 120 | 133 | |
| 121 | - if (null === $value) return $this->error; |
|
| 134 | + if (null === $value) { |
|
| 135 | + return $this->error; |
|
| 136 | + } |
|
| 122 | 137 | |
| 123 | 138 | $this->error = $value; |
| 124 | 139 | } |
@@ -12,7 +12,7 @@ |
||
| 12 | 12 | |
| 13 | 13 | public static function __autoload() { |
| 14 | 14 | |
| 15 | - self::init(DIR_DATA . 'Geo/Countries.php'); |
|
| 15 | + self::init(DIR_DATA.'Geo/Countries.php'); |
|
| 16 | 16 | } |
| 17 | 17 | } |
| 18 | 18 | } |
@@ -12,7 +12,7 @@ |
||
| 12 | 12 | |
| 13 | 13 | public static function __autoload() { |
| 14 | 14 | |
| 15 | - self::init(DIR_DATA . 'Geo/Timezones.php'); |
|
| 15 | + self::init(DIR_DATA.'Geo/Timezones.php'); |
|
| 16 | 16 | } |
| 17 | 17 | } |
| 18 | 18 | } |
@@ -45,7 +45,7 @@ |
||
| 45 | 45 | |
| 46 | 46 | public static function redirect(string $url) { |
| 47 | 47 | |
| 48 | - header("Location: " . $url); exit(); |
|
| 48 | + header("Location: ".$url); exit(); |
|
| 49 | 49 | } |
| 50 | 50 | } |
| 51 | 51 | } |
@@ -49,6 +49,9 @@ |
||
| 49 | 49 | |
| 50 | 50 | # Validate file or directory name |
| 51 | 51 | |
| 52 | + /** |
|
| 53 | + * @return string |
|
| 54 | + */ |
|
| 52 | 55 | public static function fileName(string $value) { |
| 53 | 56 | |
| 54 | 57 | return (preg_match(REGEX_FILE_NAME, $value) ? $name : false); |
@@ -12,13 +12,13 @@ |
||
| 12 | 12 | |
| 13 | 13 | # Set headers |
| 14 | 14 | |
| 15 | - $headers = ('MIME-Version: 1.0' . "\r\n"); |
|
| 15 | + $headers = ('MIME-Version: 1.0'."\r\n"); |
|
| 16 | 16 | |
| 17 | - $headers .= ('Content-Type: ' . ($is_html ? 'text/html' : 'text/plain') . '; charset=UTF-8' . "\r\n"); |
|
| 17 | + $headers .= ('Content-Type: '.($is_html ? 'text/html' : 'text/plain').'; charset=UTF-8'."\r\n"); |
|
| 18 | 18 | |
| 19 | - $headers .= ('From: ' . $sender . ' <' . $from . '>' . "\r\n" . 'Reply-To: ' . $reply_to . "\r\n"); |
|
| 19 | + $headers .= ('From: '.$sender.' <'.$from.'>'."\r\n".'Reply-To: '.$reply_to."\r\n"); |
|
| 20 | 20 | |
| 21 | - $headers .= ('X-Mailer: PHP/' . phpversion() . "\r\n"); |
|
| 21 | + $headers .= ('X-Mailer: PHP/'.phpversion()."\r\n"); |
|
| 22 | 22 | |
| 23 | 23 | # Send message |
| 24 | 24 | |
@@ -18,7 +18,7 @@ |
||
| 18 | 18 | |
| 19 | 19 | # Build query |
| 20 | 20 | |
| 21 | - $this->query = ('DELETE FROM ' . $table . ($condition ? (' WHERE (' . $condition . ')') : '')); |
|
| 21 | + $this->query = ('DELETE FROM '.$table.($condition ? (' WHERE ('.$condition.')') : '')); |
|
| 22 | 22 | } |
| 23 | 23 | } |
| 24 | 24 | } |
@@ -20,7 +20,7 @@ |
||
| 20 | 20 | |
| 21 | 21 | # Build query |
| 22 | 22 | |
| 23 | - $this->query = ('UPDATE ' . $table . ' SET ' . $dataset . ($condition ? (' WHERE (' . $condition . ')') : '')); |
|
| 23 | + $this->query = ('UPDATE '.$table.' SET '.$dataset.($condition ? (' WHERE ('.$condition.')') : '')); |
|
| 24 | 24 | } |
| 25 | 25 | } |
| 26 | 26 | } |
@@ -22,9 +22,9 @@ |
||
| 22 | 22 | |
| 23 | 23 | # Build query |
| 24 | 24 | |
| 25 | - $this->query = ('SELECT ' . $selection . ' FROM ' . $table . ($condition ? (' WHERE (' . $condition . ')') : '') . |
|
| 25 | + $this->query = ('SELECT '.$selection.' FROM '.$table.($condition ? (' WHERE ('.$condition.')') : ''). |
|
| 26 | 26 | |
| 27 | - ($order ? (' ORDER BY ' . $order) : '') . ($limit ? (' LIMIT ' . $limit) : '')); |
|
| 27 | + ($order ? (' ORDER BY '.$order) : '').($limit ? (' LIMIT '.$limit) : '')); |
|
| 28 | 28 | } |
| 29 | 29 | } |
| 30 | 30 | } |