@@ -12,11 +12,19 @@ discard block |
||
| 12 | 12 | |
| 13 | 13 | private function allocateColor(array $color = null) { |
| 14 | 14 | |
| 15 | - if (null === $this->image) return false; |
|
| 15 | + if (null === $this->image) { |
|
| 16 | + return false; |
|
| 17 | + } |
|
| 16 | 18 | |
| 17 | - if (null === $color) $color = [0, 0, 0]; else if (count($color) !== 3) return false; |
|
| 19 | + if (null === $color) { |
|
| 20 | + $color = [0, 0, 0]; |
|
| 21 | + } else if (count($color) !== 3) { |
|
| 22 | + return false; |
|
| 23 | + } |
|
| 18 | 24 | |
| 19 | - foreach (array_values($color) as $key => $value) $color[$key] = Number::format($value, 0, 255); |
|
| 25 | + foreach (array_values($color) as $key => $value) { |
|
| 26 | + $color[$key] = Number::format($value, 0, 255); |
|
| 27 | + } |
|
| 20 | 28 | |
| 21 | 29 | # ------------------------ |
| 22 | 30 | |
@@ -27,7 +35,9 @@ discard block |
||
| 27 | 35 | |
| 28 | 36 | public function __construct(int $width, int $height, array $bg_color = null) { |
| 29 | 37 | |
| 30 | - if (false === ($image = imagecreatetruecolor($width, $height))) return; |
|
| 38 | + if (false === ($image = imagecreatetruecolor($width, $height))) { |
|
| 39 | + return; |
|
| 40 | + } |
|
| 31 | 41 | |
| 32 | 42 | $this->image = $image; $this->width = $width; $this->height = $height; |
| 33 | 43 | |
@@ -41,11 +51,17 @@ discard block |
||
| 41 | 51 | |
| 42 | 52 | public function text(string $font, int $size, int $indent, int $step, string $text, array $color = null) { |
| 43 | 53 | |
| 44 | - if (null === $this->image) return false; |
|
| 54 | + if (null === $this->image) { |
|
| 55 | + return false; |
|
| 56 | + } |
|
| 45 | 57 | |
| 46 | - if (!Explorer::isFile($font)) return false; |
|
| 58 | + if (!Explorer::isFile($font)) { |
|
| 59 | + return false; |
|
| 60 | + } |
|
| 47 | 61 | |
| 48 | - if (false === ($color = $this->allocateColor($color))) return false; |
|
| 62 | + if (false === ($color = $this->allocateColor($color))) { |
|
| 63 | + return false; |
|
| 64 | + } |
|
| 49 | 65 | |
| 50 | 66 | $base = (floor(($this->height - $size) / 2) + $size); |
| 51 | 67 | |
@@ -65,13 +81,22 @@ discard block |
||
| 65 | 81 | |
| 66 | 82 | public function noise(int $rate, array $color = null) { |
| 67 | 83 | |
| 68 | - if (null === $this->image) return false; |
|
| 84 | + if (null === $this->image) { |
|
| 85 | + return false; |
|
| 86 | + } |
|
| 69 | 87 | |
| 70 | - if (false === ($color = $this->allocateColor($color))) return false; |
|
| 88 | + if (false === ($color = $this->allocateColor($color))) { |
|
| 89 | + return false; |
|
| 90 | + } |
|
| 71 | 91 | |
| 72 | - for ($x = 0; $x < $this->width; $x++) for ($y = 0; $y < $this->height; $y++) { |
|
| 92 | + for ($x = 0; $x < $this->width; $x++) { |
|
| 93 | + for ($y = 0; |
|
| 94 | + } |
|
| 95 | + $y < $this->height; $y++) { |
|
| 73 | 96 | |
| 74 | - if (random_int(1, $rate) === 1) imagesetpixel($this->image, $x, $y, $color); |
|
| 97 | + if (random_int(1, $rate) === 1) { |
|
| 98 | + imagesetpixel($this->image, $x, $y, $color); |
|
| 99 | + } |
|
| 75 | 100 | } |
| 76 | 101 | |
| 77 | 102 | # ------------------------ |
@@ -83,9 +108,13 @@ discard block |
||
| 83 | 108 | |
| 84 | 109 | public function lines(int $count, array $color = null) { |
| 85 | 110 | |
| 86 | - if (null === $this->image) return false; |
|
| 111 | + if (null === $this->image) { |
|
| 112 | + return false; |
|
| 113 | + } |
|
| 87 | 114 | |
| 88 | - if (false === ($color = $this->allocateColor($color))) return false; |
|
| 115 | + if (false === ($color = $this->allocateColor($color))) { |
|
| 116 | + return false; |
|
| 117 | + } |
|
| 89 | 118 | |
| 90 | 119 | for ($i = 0; $i < $count; $i++) { |
| 91 | 120 | |
@@ -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 | } |