@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | */ |
| 17 | 17 | protected $data; |
| 18 | 18 | |
| 19 | - public function __construct ($twig) |
|
| 19 | + public function __construct($twig) |
|
| 20 | 20 | { |
| 21 | 21 | $this->twig = $twig; |
| 22 | 22 | $this->data = []; |
@@ -28,7 +28,7 @@ discard block |
||
| 28 | 28 | * @param array $data |
| 29 | 29 | * @return self |
| 30 | 30 | */ |
| 31 | - public function bind (array $data) : TemplateInterface |
|
| 31 | + public function bind(array $data) : TemplateInterface |
|
| 32 | 32 | { |
| 33 | 33 | $this->data = array_merge($this->data, $data); |
| 34 | 34 | return $this; |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | * |
| 53 | 53 | * @return self |
| 54 | 54 | */ |
| 55 | - public function clear () : TemplateInterface |
|
| 55 | + public function clear() : TemplateInterface |
|
| 56 | 56 | { |
| 57 | 57 | $this->data = []; |
| 58 | 58 | return $this; |
@@ -18,8 +18,9 @@ discard block |
||
| 18 | 18 | */ |
| 19 | 19 | public function print(\Exception $e) : string |
| 20 | 20 | { |
| 21 | - if ($e instanceof ParseException) |
|
| 22 | - return $this->printParseException($e); |
|
| 21 | + if ($e instanceof ParseException) { |
|
| 22 | + return $this->printParseException($e); |
|
| 23 | + } |
|
| 23 | 24 | |
| 24 | 25 | return "<error>{$e}</error>"; |
| 25 | 26 | } |
@@ -36,10 +37,12 @@ discard block |
||
| 36 | 37 | $error = ''; |
| 37 | 38 | if ($syntax instanceof ObjectSyntax) { |
| 38 | 39 | $i = $e->extra(); |
| 39 | - if ($i['type'] == 'invalid-field') |
|
| 40 | - $error = "{$i['field']} is invalid!"; |
|
| 41 | - if ($i['type'] == 'missing-field') |
|
| 42 | - $error = "{$i['field']} is missing!"; |
|
| 40 | + if ($i['type'] == 'invalid-field') { |
|
| 41 | + $error = "{$i['field']} is invalid!"; |
|
| 42 | + } |
|
| 43 | + if ($i['type'] == 'missing-field') { |
|
| 44 | + $error = "{$i['field']} is missing!"; |
|
| 45 | + } |
|
| 43 | 46 | if ($i['type'] == 'additional-items') { |
| 44 | 47 | $items = implode($syntax->separator(), $i['items']); |
| 45 | 48 | $error = "additional items {$items}"; |
@@ -48,8 +51,9 @@ discard block |
||
| 48 | 51 | $syntax = $this->printSyntax($e->syntax()); |
| 49 | 52 | |
| 50 | 53 | $output = "<reset>Failed to parse <warn>'{$e->input()}'</warn> as <info>{$syntax}</info>"; |
| 51 | - if ('' != $error) |
|
| 52 | - $output .= " <error>{$error}</error>"; |
|
| 54 | + if ('' != $error) { |
|
| 55 | + $output .= " <error>{$error}</error>"; |
|
| 56 | + } |
|
| 53 | 57 | |
| 54 | 58 | $previous = $e->previous(); |
| 55 | 59 | if ($previous) { |
@@ -62,11 +66,15 @@ discard block |
||
| 62 | 66 | protected function printSyntax(Syntax $s, bool $short = false) : string |
| 63 | 67 | { |
| 64 | 68 | if ($s instanceof ObjectSyntax) { |
| 65 | - if ($short) return 'object'; |
|
| 69 | + if ($short) { |
|
| 70 | + return 'object'; |
|
| 71 | + } |
|
| 66 | 72 | return implode($s->separator(), array_keys($s->fields())); |
| 67 | 73 | } |
| 68 | 74 | if ($s instanceof ArraySyntax) { |
| 69 | - if ($short) return 'array'; |
|
| 75 | + if ($short) { |
|
| 76 | + return 'array'; |
|
| 77 | + } |
|
| 70 | 78 | return $this->printSyntax($s->syntax()).$s->separator().'...'; |
| 71 | 79 | } |
| 72 | 80 | return (string) $s; |