@@ -24,11 +24,11 @@ |
||
24 | 24 | */ |
25 | 25 | protected function deleteDeclaration(string $class): void |
26 | 26 | { |
27 | - if (class_exists($class)) { |
|
28 | - try { |
|
27 | + if (class_exists($class)){ |
|
28 | + try{ |
|
29 | 29 | $reflection = new ReflectionClass($class); |
30 | 30 | $this->files()->delete($reflection->getFileName()); |
31 | - } catch (Throwable $exception) { |
|
31 | + }catch (Throwable $exception){ |
|
32 | 32 | } |
33 | 33 | } |
34 | 34 | } |
@@ -24,11 +24,15 @@ |
||
24 | 24 | */ |
25 | 25 | protected function deleteDeclaration(string $class): void |
26 | 26 | { |
27 | - if (class_exists($class)) { |
|
28 | - try { |
|
27 | + if (class_exists($class)) |
|
28 | + { |
|
29 | + try |
|
30 | + { |
|
29 | 31 | $reflection = new ReflectionClass($class); |
30 | 32 | $this->files()->delete($reflection->getFileName()); |
31 | - } catch (Throwable $exception) { |
|
33 | + } |
|
34 | + catch (Throwable $exception) |
|
35 | + { |
|
32 | 36 | } |
33 | 37 | } |
34 | 38 | } |
@@ -61,18 +61,18 @@ |
||
61 | 61 | */ |
62 | 62 | protected function mapDirectories(array $directories): array |
63 | 63 | { |
64 | - if (!isset($directories['root'])) { |
|
64 | + if (!isset($directories['root'])){ |
|
65 | 65 | throw new Boot\Exception\BootException('Missing required directory `root`.'); |
66 | 66 | } |
67 | 67 | |
68 | - if (!isset($directories['app'])) { |
|
69 | - $directories['app'] = $directories['root'] . '/'; |
|
68 | + if (!isset($directories['app'])){ |
|
69 | + $directories['app'] = $directories['root'].'/'; |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | return array_merge([ |
73 | - 'vendor' => $directories['root'] . '/vendor/', |
|
74 | - 'runtime' => $directories['root'] . '/runtime/', |
|
75 | - 'config' => $directories['app'] . '/config/' |
|
73 | + 'vendor' => $directories['root'].'/vendor/', |
|
74 | + 'runtime' => $directories['root'].'/runtime/', |
|
75 | + 'config' => $directories['app'].'/config/' |
|
76 | 76 | ], $directories); |
77 | 77 | } |
78 | 78 | } |
@@ -61,11 +61,13 @@ |
||
61 | 61 | */ |
62 | 62 | protected function mapDirectories(array $directories): array |
63 | 63 | { |
64 | - if (!isset($directories['root'])) { |
|
64 | + if (!isset($directories['root'])) |
|
65 | + { |
|
65 | 66 | throw new Boot\Exception\BootException('Missing required directory `root`.'); |
66 | 67 | } |
67 | 68 | |
68 | - if (!isset($directories['app'])) { |
|
69 | + if (!isset($directories['app'])) |
|
70 | + { |
|
69 | 71 | $directories['app'] = $directories['root'] . '/'; |
70 | 72 | } |
71 | 73 |
@@ -14,7 +14,7 @@ |
||
14 | 14 | declare(strict_types=1); |
15 | 15 | |
16 | 16 | return [ |
17 | - 'directory' => directory('app') . 'migrations/', |
|
17 | + 'directory' => directory('app').'migrations/', |
|
18 | 18 | 'database' => 'runtime', |
19 | 19 | 'table' => 'migrations', |
20 | 20 | 'safe' => env('SPIRAL_ENV') === 'develop' |
@@ -33,7 +33,7 @@ |
||
33 | 33 | 'connections' => [ |
34 | 34 | 'runtime' => [ |
35 | 35 | 'driver' => SQLiteDriver::class, |
36 | - 'connection' => 'sqlite:' . directory('runtime') . 'runtime.db', |
|
36 | + 'connection' => 'sqlite:'.directory('runtime').'runtime.db', |
|
37 | 37 | 'profiling' => env('DEBUG', false), |
38 | 38 | 'username' => 'sqlite', |
39 | 39 | 'password' => '', |
@@ -26,9 +26,9 @@ discard block |
||
26 | 26 | public function testFromEntity(): void |
27 | 27 | { |
28 | 28 | $line = __LINE__; |
29 | - $className = __NAMESPACE__ . "\\App\\Request\\Sample{$line}Request"; |
|
29 | + $className = __NAMESPACE__."\\App\\Request\\Sample{$line}Request"; |
|
30 | 30 | $output = $this->console()->run('create:filter', [ |
31 | - 'name' => 'sample' . $line, |
|
31 | + 'name' => 'sample'.$line, |
|
32 | 32 | '--entity' => SourceEntity74::class |
33 | 33 | ]); |
34 | 34 | |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | |
40 | 40 | $reflection = new ReflectionClass($className); |
41 | 41 | |
42 | - try { |
|
42 | + try{ |
|
43 | 43 | $schema = $reflection->getConstant('SCHEMA'); |
44 | 44 | $this->assertSame('data:typedBool', $schema['typedBool']); |
45 | 45 | $this->assertSame('data:noTypeString', $schema['noTypeString']); |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | $this->assertSame(['notEmpty', 'string'], $validates['obj']); |
54 | 54 | $this->assertSame(['notEmpty', 'integer'], $validates['intFromPhpDoc']); |
55 | 55 | $this->assertSame(['notEmpty', 'float'], $validates['noTypeWithFloatDefault']); |
56 | - } finally { |
|
56 | + }finally{ |
|
57 | 57 | $this->deleteDeclaration($className); |
58 | 58 | } |
59 | 59 | } |
@@ -39,7 +39,8 @@ discard block |
||
39 | 39 | |
40 | 40 | $reflection = new ReflectionClass($className); |
41 | 41 | |
42 | - try { |
|
42 | + try |
|
43 | + { |
|
43 | 44 | $schema = $reflection->getConstant('SCHEMA'); |
44 | 45 | $this->assertSame('data:typedBool', $schema['typedBool']); |
45 | 46 | $this->assertSame('data:noTypeString', $schema['noTypeString']); |
@@ -53,7 +54,9 @@ discard block |
||
53 | 54 | $this->assertSame(['notEmpty', 'string'], $validates['obj']); |
54 | 55 | $this->assertSame(['notEmpty', 'integer'], $validates['intFromPhpDoc']); |
55 | 56 | $this->assertSame(['notEmpty', 'float'], $validates['noTypeWithFloatDefault']); |
56 | - } finally { |
|
57 | + } |
|
58 | + finally |
|
59 | + { |
|
57 | 60 | $this->deleteDeclaration($className); |
58 | 61 | } |
59 | 62 | } |
@@ -26,7 +26,7 @@ |
||
26 | 26 | public function testFromEntity(): void |
27 | 27 | { |
28 | 28 | $line = __LINE__; |
29 | - $className = __NAMESPACE__ . "\\App\\Request\\Sample{$line}Request"; |
|
29 | + $className = __NAMESPACE__ . "\\App\\Request\\Sample{$line}request"; |
|
30 | 30 | $output = $this->console()->run('create:filter', [ |
31 | 31 | 'name' => 'sample' . $line, |
32 | 32 | '--entity' => SourceEntity74::class |
@@ -38,14 +38,14 @@ discard block |
||
38 | 38 | $input = clone $this; |
39 | 39 | |
40 | 40 | $namespace = trim($namespace); |
41 | - if ($namespace === '') { |
|
41 | + if ($namespace === ''){ |
|
42 | 42 | return $input; |
43 | 43 | } |
44 | 44 | |
45 | 45 | $input->data = []; |
46 | 46 | |
47 | 47 | $data = $this->getValue($namespace, []); |
48 | - if (is_array($data)) { |
|
48 | + if (is_array($data)){ |
|
49 | 49 | $input->data = $data; |
50 | 50 | } |
51 | 51 | |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | */ |
58 | 58 | public function getValue(string $option, $default = null) |
59 | 59 | { |
60 | - if (!$this->hasValue($option)) { |
|
60 | + if (!$this->hasValue($option)){ |
|
61 | 61 | return $default; |
62 | 62 | } |
63 | 63 |
@@ -38,14 +38,16 @@ discard block |
||
38 | 38 | $input = clone $this; |
39 | 39 | |
40 | 40 | $namespace = trim($namespace); |
41 | - if ($namespace === '') { |
|
41 | + if ($namespace === '') |
|
42 | + { |
|
42 | 43 | return $input; |
43 | 44 | } |
44 | 45 | |
45 | 46 | $input->data = []; |
46 | 47 | |
47 | 48 | $data = $this->getValue($namespace, []); |
48 | - if (is_array($data)) { |
|
49 | + if (is_array($data)) |
|
50 | + { |
|
49 | 51 | $input->data = $data; |
50 | 52 | } |
51 | 53 | |
@@ -57,7 +59,8 @@ discard block |
||
57 | 59 | */ |
58 | 60 | public function getValue(string $option, $default = null) |
59 | 61 | { |
60 | - if (!$this->hasValue($option)) { |
|
62 | + if (!$this->hasValue($option)) |
|
63 | + { |
|
61 | 64 | return $default; |
62 | 65 | } |
63 | 66 |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | */ |
41 | 41 | public function addFilter(string $name, FilterInterface $filter): void |
42 | 42 | { |
43 | - if ($this->hasFilter($name)) { |
|
43 | + if ($this->hasFilter($name)){ |
|
44 | 44 | throw new SchemaException("Filter `$name` is already defined"); |
45 | 45 | } |
46 | 46 | |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | */ |
66 | 66 | public function getFilter(string $name): FilterInterface |
67 | 67 | { |
68 | - if (!$this->hasFilter($name)) { |
|
68 | + if (!$this->hasFilter($name)){ |
|
69 | 69 | throw new SchemaException("No such filter `$name`"); |
70 | 70 | } |
71 | 71 | |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | */ |
90 | 90 | public function addSorter(string $name, SorterInterface $sorter): void |
91 | 91 | { |
92 | - if ($this->hasSorter($name)) { |
|
92 | + if ($this->hasSorter($name)){ |
|
93 | 93 | throw new SchemaException("Sorter `$name` is already defined"); |
94 | 94 | } |
95 | 95 | |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | */ |
115 | 115 | public function getSorter(string $name): SorterInterface |
116 | 116 | { |
117 | - if (!$this->hasSorter($name)) { |
|
117 | + if (!$this->hasSorter($name)){ |
|
118 | 118 | throw new SchemaException("No such sorter `$name`"); |
119 | 119 | } |
120 | 120 |
@@ -40,7 +40,8 @@ discard block |
||
40 | 40 | */ |
41 | 41 | public function addFilter(string $name, FilterInterface $filter): void |
42 | 42 | { |
43 | - if ($this->hasFilter($name)) { |
|
43 | + if ($this->hasFilter($name)) |
|
44 | + { |
|
44 | 45 | throw new SchemaException("Filter `$name` is already defined"); |
45 | 46 | } |
46 | 47 | |
@@ -65,7 +66,8 @@ discard block |
||
65 | 66 | */ |
66 | 67 | public function getFilter(string $name): FilterInterface |
67 | 68 | { |
68 | - if (!$this->hasFilter($name)) { |
|
69 | + if (!$this->hasFilter($name)) |
|
70 | + { |
|
69 | 71 | throw new SchemaException("No such filter `$name`"); |
70 | 72 | } |
71 | 73 | |
@@ -89,7 +91,8 @@ discard block |
||
89 | 91 | */ |
90 | 92 | public function addSorter(string $name, SorterInterface $sorter): void |
91 | 93 | { |
92 | - if ($this->hasSorter($name)) { |
|
94 | + if ($this->hasSorter($name)) |
|
95 | + { |
|
93 | 96 | throw new SchemaException("Sorter `$name` is already defined"); |
94 | 97 | } |
95 | 98 | |
@@ -114,7 +117,8 @@ discard block |
||
114 | 117 | */ |
115 | 118 | public function getSorter(string $name): SorterInterface |
116 | 119 | { |
117 | - if (!$this->hasSorter($name)) { |
|
120 | + if (!$this->hasSorter($name)) |
|
121 | + { |
|
118 | 122 | throw new SchemaException("No such sorter `$name`"); |
119 | 123 | } |
120 | 124 |
@@ -36,7 +36,7 @@ |
||
36 | 36 | $sorter = clone $this; |
37 | 37 | $sorter->sorters = []; |
38 | 38 | |
39 | - foreach ($this->sorters as $s) { |
|
39 | + foreach ($this->sorters as $s){ |
|
40 | 40 | $sorter->sorters[] = $s->withDirection($direction); |
41 | 41 | } |
42 | 42 |
@@ -36,7 +36,8 @@ |
||
36 | 36 | $sorter = clone $this; |
37 | 37 | $sorter->sorters = []; |
38 | 38 | |
39 | - foreach ($this->sorters as $s) { |
|
39 | + foreach ($this->sorters as $s) |
|
40 | + { |
|
40 | 41 | $sorter->sorters[] = $s->withDirection($direction); |
41 | 42 | } |
42 | 43 |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | $sorter = clone $this; |
48 | 48 | $sorter->direction = $sorter->checkDirection($direction); |
49 | 49 | |
50 | - switch ($sorter->direction) { |
|
50 | + switch ($sorter->direction){ |
|
51 | 51 | case self::ASC: |
52 | 52 | $sorter->sorter = $sorter->asc->withDirection(self::ASC); |
53 | 53 | break; |
@@ -76,21 +76,21 @@ discard block |
||
76 | 76 | */ |
77 | 77 | private function checkDirection($direction): ?string |
78 | 78 | { |
79 | - if (is_string($direction)) { |
|
80 | - if (strtolower($direction) === self::DESC) { |
|
79 | + if (is_string($direction)){ |
|
80 | + if (strtolower($direction) === self::DESC){ |
|
81 | 81 | return self::DESC; |
82 | 82 | } |
83 | 83 | |
84 | - if (strtolower($direction) === self::ASC) { |
|
84 | + if (strtolower($direction) === self::ASC){ |
|
85 | 85 | return self::ASC; |
86 | 86 | } |
87 | 87 | } |
88 | 88 | |
89 | - if (in_array($direction, ['-1', -1, SORT_DESC], true)) { |
|
89 | + if (in_array($direction, ['-1', -1, SORT_DESC], true)){ |
|
90 | 90 | return self::DESC; |
91 | 91 | } |
92 | 92 | |
93 | - if (in_array($direction, ['1', 1, SORT_ASC], true)) { |
|
93 | + if (in_array($direction, ['1', 1, SORT_ASC], true)){ |
|
94 | 94 | return self::ASC; |
95 | 95 | } |
96 | 96 |
@@ -47,7 +47,8 @@ discard block |
||
47 | 47 | $sorter = clone $this; |
48 | 48 | $sorter->direction = $sorter->checkDirection($direction); |
49 | 49 | |
50 | - switch ($sorter->direction) { |
|
50 | + switch ($sorter->direction) |
|
51 | + { |
|
51 | 52 | case self::ASC: |
52 | 53 | $sorter->sorter = $sorter->asc->withDirection(self::ASC); |
53 | 54 | break; |
@@ -76,21 +77,26 @@ discard block |
||
76 | 77 | */ |
77 | 78 | private function checkDirection($direction): ?string |
78 | 79 | { |
79 | - if (is_string($direction)) { |
|
80 | - if (strtolower($direction) === self::DESC) { |
|
80 | + if (is_string($direction)) |
|
81 | + { |
|
82 | + if (strtolower($direction) === self::DESC) |
|
83 | + { |
|
81 | 84 | return self::DESC; |
82 | 85 | } |
83 | 86 | |
84 | - if (strtolower($direction) === self::ASC) { |
|
87 | + if (strtolower($direction) === self::ASC) |
|
88 | + { |
|
85 | 89 | return self::ASC; |
86 | 90 | } |
87 | 91 | } |
88 | 92 | |
89 | - if (in_array($direction, ['-1', -1, SORT_DESC], true)) { |
|
93 | + if (in_array($direction, ['-1', -1, SORT_DESC], true)) |
|
94 | + { |
|
90 | 95 | return self::DESC; |
91 | 96 | } |
92 | 97 | |
93 | - if (in_array($direction, ['1', 1, SORT_ASC], true)) { |
|
98 | + if (in_array($direction, ['1', 1, SORT_ASC], true)) |
|
99 | + { |
|
94 | 100 | return self::ASC; |
95 | 101 | } |
96 | 102 |