@@ -85,7 +85,7 @@ |
||
| 85 | 85 | { |
| 86 | 86 | $html = TagToString::format($this); |
| 87 | 87 | if (!is_null($this->_method)) { |
| 88 | - $html .= "\n<input type=\"hidden\" name=\"{$this->_token_name}\" value=\"" . $this->_method . "\" />"; |
|
| 88 | + $html .= "\n<input type=\"hidden\" name=\"{$this->_token_name}\" value=\"".$this->_method."\" />"; |
|
| 89 | 89 | } |
| 90 | 90 | return $html; |
| 91 | 91 | } |
@@ -27,7 +27,7 @@ discard block |
||
| 27 | 27 | { |
| 28 | 28 | $this->multiple = $multiple; |
| 29 | 29 | $name = $this->get('name'); |
| 30 | - $this->setAttribute('name', $name . '[]'); |
|
| 30 | + $this->setAttribute('name', $name.'[]'); |
|
| 31 | 31 | return $this; |
| 32 | 32 | } |
| 33 | 33 | |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | $id = $this->getName(); |
| 69 | 69 | $id = str_replace(['[', ']', '_'], '-', $id); |
| 70 | 70 | if (in_array($this->get('type'), ['radio', 'checkbox'])) { |
| 71 | - $id .= '-' . $this->get('value'); |
|
| 71 | + $id .= '-'.$this->get('value'); |
|
| 72 | 72 | } |
| 73 | 73 | } |
| 74 | 74 | $this->setAttribute('id', $id); |
@@ -13,8 +13,14 @@ |
||
| 13 | 13 | */ |
| 14 | 14 | private $label; |
| 15 | 15 | |
| 16 | + /** |
|
| 17 | + * @param string $name |
|
| 18 | + */ |
|
| 16 | 19 | abstract public function get($name); |
| 17 | 20 | |
| 21 | + /** |
|
| 22 | + * @param string $key |
|
| 23 | + */ |
|
| 18 | 24 | abstract public function setAttribute($key, $value = true, $sep = false); |
| 19 | 25 | |
| 20 | 26 | /** |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | if ((is_array($data))) { |
| 35 | 35 | return true; |
| 36 | 36 | } |
| 37 | - if (is_object($data) && $data instanceof ArrayAccess) { |
|
| 37 | + if (is_object($data) && $data instanceof ArrayAccess) { |
|
| 38 | 38 | return true; |
| 39 | 39 | } |
| 40 | 40 | return false; |
@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | */ |
| 49 | 49 | public static function getArray($data, $key, $default = null) |
| 50 | 50 | { |
| 51 | - return array_key_exists($key, $data) ? $data[$key]: $default; |
|
| 51 | + return array_key_exists($key, $data) ? $data[$key] : $default; |
|
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | /** |
@@ -59,11 +59,11 @@ discard block |
||
| 59 | 59 | */ |
| 60 | 60 | public static function getObj($data, $key, $default = null) |
| 61 | 61 | { |
| 62 | - $method = 'get' . $key; |
|
| 62 | + $method = 'get'.$key; |
|
| 63 | 63 | if (method_exists($data, $method)) { |
| 64 | 64 | return $data->$method(); |
| 65 | 65 | } |
| 66 | - $method = 'get' . str_replace('_', '', $key); |
|
| 66 | + $method = 'get'.str_replace('_', '', $key); |
|
| 67 | 67 | if (method_exists($data, $method)) { |
| 68 | 68 | return $data->$method(); |
| 69 | 69 | } |
@@ -90,10 +90,10 @@ discard block |
||
| 90 | 90 | if (!is_object($data)) { |
| 91 | 91 | return false; |
| 92 | 92 | } |
| 93 | - if (method_exists($data, 'get' . $key)) { |
|
| 93 | + if (method_exists($data, 'get'.$key)) { |
|
| 94 | 94 | return true; |
| 95 | 95 | } |
| 96 | - if (method_exists($data, 'get' . str_replace('_', '', $key))) { |
|
| 96 | + if (method_exists($data, 'get'.str_replace('_', '', $key))) { |
|
| 97 | 97 | return true; |
| 98 | 98 | } |
| 99 | 99 | if (isset($data->$key)) { |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | $start ?: date('Y') - 1, |
| 18 | 18 | $end ?: date('Y') + 1, |
| 19 | 19 | $step, |
| 20 | - function ($year) { |
|
| 20 | + function($year) { |
|
| 21 | 21 | return sprintf('%04d', $year); |
| 22 | 22 | }); |
| 23 | 23 | } |
@@ -37,15 +37,15 @@ discard block |
||
| 37 | 37 | */ |
| 38 | 38 | public static function formatJpnGenGou() |
| 39 | 39 | { |
| 40 | - $genGou = [ // until => genGou name |
|
| 40 | + $genGou = [// until => genGou name |
|
| 41 | 41 | '1868' => false, // end of genGou, specified by false. |
| 42 | 42 | '1911' => '明治', |
| 43 | 43 | '1925' => '大正', |
| 44 | 44 | '1988' => '昭和', |
| 45 | 45 | '9999' => '平成', // so far... |
| 46 | 46 | ]; |
| 47 | - return function ($year) use ($genGou) { |
|
| 48 | - $year = (int)$year; |
|
| 47 | + return function($year) use ($genGou) { |
|
| 48 | + $year = (int) $year; |
|
| 49 | 49 | $start = 0; |
| 50 | 50 | /** @var string|bool $gou */ |
| 51 | 51 | foreach ($genGou as $ends => $gou) { |
@@ -57,11 +57,11 @@ discard block |
||
| 57 | 57 | if ($year == 1) { |
| 58 | 58 | $year = '元'; |
| 59 | 59 | } |
| 60 | - return $gou . $year . '年'; |
|
| 60 | + return $gou.$year.'年'; |
|
| 61 | 61 | } |
| 62 | 62 | $start = $ends; |
| 63 | 63 | } |
| 64 | - return '西暦' . $year . '年'; |
|
| 64 | + return '西暦'.$year.'年'; |
|
| 65 | 65 | }; |
| 66 | 66 | } |
| 67 | 67 | |
@@ -42,7 +42,7 @@ |
||
| 42 | 42 | { |
| 43 | 43 | $html = TagToString::format($this); |
| 44 | 44 | if ($this->label) { |
| 45 | - $html = $this->labelHtml($html . ' ' . $this->label); |
|
| 45 | + $html = $this->labelHtml($html.' '.$this->label); |
|
| 46 | 46 | } |
| 47 | 47 | return $html; |
| 48 | 48 | } |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | */ |
| 70 | 70 | public function onlyOne() |
| 71 | 71 | { |
| 72 | - $serious = $this->findMostSerious(); |
|
| 72 | + $serious = $this->findMostSerious(); |
|
| 73 | 73 | if (!empty($serious)) { |
| 74 | 74 | return $this->show($serious); |
| 75 | 75 | } |
@@ -86,9 +86,9 @@ discard block |
||
| 86 | 86 | self::ALERT => 2, |
| 87 | 87 | self::MESSAGE => 1, |
| 88 | 88 | ]; |
| 89 | - $serious = array_reduce( |
|
| 89 | + $serious = array_reduce( |
|
| 90 | 90 | $this->messages, |
| 91 | - function ($carry, $msg) use ($msgScores) { |
|
| 91 | + function($carry, $msg) use ($msgScores) { |
|
| 92 | 92 | $myScore = $msgScores[$msg['type']]; |
| 93 | 93 | $msg['score'] = $myScore; |
| 94 | 94 | return $myScore > $carry['score'] ? $msg : $carry; |
@@ -119,7 +119,7 @@ discard block |
||
| 119 | 119 | */ |
| 120 | 120 | public function getIterator() |
| 121 | 121 | { |
| 122 | - foreach($this->messages as $message) { |
|
| 122 | + foreach ($this->messages as $message) { |
|
| 123 | 123 | yield $message['type'] => $message['message']; |
| 124 | 124 | } |
| 125 | 125 | } |
@@ -142,8 +142,8 @@ |
||
| 142 | 142 | } elseif ($sep === false) { |
| 143 | 143 | $this->attributes[$key] = $value; |
| 144 | 144 | } else { |
| 145 | - $sep = (string)$sep; |
|
| 146 | - $this->attributes[$key] .= $sep . $value; |
|
| 145 | + $sep = (string) $sep; |
|
| 146 | + $this->attributes[$key] .= $sep.$value; |
|
| 147 | 147 | } |
| 148 | 148 | return $this; |
| 149 | 149 | } |
@@ -26,7 +26,7 @@ discard block |
||
| 26 | 26 | $this->list = $list; |
| 27 | 27 | $this->setAttribute('type', $type); |
| 28 | 28 | $this->setAttribute('name', $name); |
| 29 | - $this->setAttribute('value', (array)$value); |
|
| 29 | + $this->setAttribute('value', (array) $value); |
|
| 30 | 30 | if ($type === 'checkbox') { |
| 31 | 31 | $this->setMultiple(); |
| 32 | 32 | } |
@@ -48,9 +48,9 @@ discard block |
||
| 48 | 48 | $html = '<ul>'; |
| 49 | 49 | foreach ($this->list as $key => $label) { |
| 50 | 50 | $html .= "\n"; |
| 51 | - $html .= ' <li>' . $this->labelHtml($this->getInput($key) . ' ' . $label) . '</li>'; |
|
| 51 | + $html .= ' <li>'.$this->labelHtml($this->getInput($key).' '.$label).'</li>'; |
|
| 52 | 52 | } |
| 53 | - return $html . "\n</ul>"; |
|
| 53 | + return $html."\n</ul>"; |
|
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | /** |
@@ -83,7 +83,7 @@ discard block |
||
| 83 | 83 | $input->fillAttributes($this->getAttribute()->getAttribute()); |
| 84 | 84 | $input->setAttribute('value', $key); |
| 85 | 85 | $selectedValue = $this->get('value'); |
| 86 | - if (in_array((string)$key, $selectedValue)) { |
|
| 86 | + if (in_array((string) $key, $selectedValue)) { |
|
| 87 | 87 | $input->setAttribute('checked', true); |
| 88 | 88 | } |
| 89 | 89 | return $input; |
@@ -12,9 +12,9 @@ discard block |
||
| 12 | 12 | $prop = (string) $element->getAttribute(); |
| 13 | 13 | $tag = $element->getTagName(); |
| 14 | 14 | if ($element->isClosed() || $element->hasContents()) { |
| 15 | - $html = '<' . $tag . $prop . ' >' . $element->getContents() . "</{$tag}>" . "\n"; |
|
| 15 | + $html = '<'.$tag.$prop.' >'.$element->getContents()."</{$tag}>"."\n"; |
|
| 16 | 16 | } else { |
| 17 | - $html = '<' . $tag . $prop . ' >' . "\n"; |
|
| 17 | + $html = '<'.$tag.$prop.' >'."\n"; |
|
| 18 | 18 | } |
| 19 | 19 | $html = rtrim($html); |
| 20 | 20 | return $html; |
@@ -38,7 +38,7 @@ discard block |
||
| 38 | 38 | } |
| 39 | 39 | $property[] = "{$key}=\"{$val}\""; |
| 40 | 40 | } |
| 41 | - return ' ' . implode(' ', $property); |
|
| 41 | + return ' '.implode(' ', $property); |
|
| 42 | 42 | } |
| 43 | 43 | return ''; |
| 44 | 44 | } |
@@ -29,8 +29,12 @@ |
||
| 29 | 29 | if ($attributes = $element->getAttribute()) { |
| 30 | 30 | $property = []; |
| 31 | 31 | foreach ($attributes as $key => $val) { |
| 32 | - if ($val === false) continue; |
|
| 33 | - if ($key === 'value' && '' === (string) $val) continue; |
|
| 32 | + if ($val === false) { |
|
| 33 | + continue; |
|
| 34 | + } |
|
| 35 | + if ($key === 'value' && '' === (string) $val) { |
|
| 36 | + continue; |
|
| 37 | + } |
|
| 34 | 38 | if (is_numeric($key)) { |
| 35 | 39 | $key = $val; |
| 36 | 40 | } elseif ($val === true) { |