@@ -56,7 +56,7 @@ |
||
56 | 56 | * @param \suda\orm\middleware\Middleware|null $middleware |
57 | 57 | * @return DataAccess |
58 | 58 | */ |
59 | - public static function new(string $object, ?Middleware $middleware = null):DataAccess |
|
59 | + public static function new(string $object, ?Middleware $middleware = null) : DataAccess |
|
60 | 60 | { |
61 | 61 | return new self($object, $middleware); |
62 | 62 | } |
@@ -139,7 +139,7 @@ |
||
139 | 139 | if (is_string($doc) && preg_match('/@field\s+(\w+)(?:\((.+?)\))?\s+(.+)?$/im', $doc, $match)) { |
140 | 140 | $type = strtoupper($match[1]); |
141 | 141 | $length = static::parseLength($match[2] ?? ''); |
142 | - return [$type, $length , trim($match[3] ?? '')]; |
|
142 | + return [$type, $length, trim($match[3] ?? '')]; |
|
143 | 143 | } |
144 | 144 | } |
145 | 145 | return ['text', null, '']; |
@@ -51,10 +51,10 @@ discard block |
||
51 | 51 | public function input(string $name, $data) |
52 | 52 | { |
53 | 53 | if (array_key_exists($name, $this->processor)) { |
54 | - if ($this->processor[$name] === ObjectMiddleware::SERIALIZE){ |
|
55 | - return $data === null? $data : \serialize($data); |
|
54 | + if ($this->processor[$name] === ObjectMiddleware::SERIALIZE) { |
|
55 | + return $data === null ? $data : \serialize($data); |
|
56 | 56 | } |
57 | - if ($this->processor[$name] === ObjectMiddleware::JSON){ |
|
57 | + if ($this->processor[$name] === ObjectMiddleware::JSON) { |
|
58 | 58 | return \json_encode($data); |
59 | 59 | } |
60 | 60 | } |
@@ -71,10 +71,10 @@ discard block |
||
71 | 71 | public function output(string $name, $data) |
72 | 72 | { |
73 | 73 | if (array_key_exists($name, $this->processor)) { |
74 | - if ($this->processor[$name] === ObjectMiddleware::SERIALIZE){ |
|
74 | + if ($this->processor[$name] === ObjectMiddleware::SERIALIZE) { |
|
75 | 75 | return \unserialize($data) ?: null; |
76 | 76 | } |
77 | - if ($this->processor[$name] === ObjectMiddleware::JSON){ |
|
77 | + if ($this->processor[$name] === ObjectMiddleware::JSON) { |
|
78 | 78 | return \json_decode($data); |
79 | 79 | } |
80 | 80 | } |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | if ($doc = $property->getDocComment()) { |
108 | 108 | if (is_string($doc) && preg_match('/@var\s+(\w+)/i', $doc, $match)) { |
109 | 109 | $type = \strtolower($match[1]); |
110 | - if (\in_array($type, ['boolean', 'bool', 'integer', 'int' , 'float' , 'double', 'string'])) { |
|
110 | + if (\in_array($type, ['boolean', 'bool', 'integer', 'int', 'float', 'double', 'string'])) { |
|
111 | 111 | return ObjectMiddleware::RAW; |
112 | 112 | } |
113 | 113 | } |
@@ -60,7 +60,7 @@ |
||
60 | 60 | protected function prepareProcessorSet(string $object) |
61 | 61 | { |
62 | 62 | $reflectObject = new ReflectionClass($object); |
63 | - $classDoc = is_string($reflectObject->getDocComment())?$reflectObject->getDocComment():''; |
|
63 | + $classDoc = is_string($reflectObject->getDocComment()) ? $reflectObject->getDocComment() : ''; |
|
64 | 64 | $field = TableClassStructBuilder::readClassDocField($classDoc); |
65 | 65 | if ($field !== null) { |
66 | 66 | $this->createProccorFromStruct(); |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | */ |
192 | 192 | private function inputSerialize($data) |
193 | 193 | { |
194 | - return $data === null? $data : \serialize($data); |
|
194 | + return $data === null ? $data : \serialize($data); |
|
195 | 195 | } |
196 | 196 | |
197 | 197 | /** |
@@ -213,7 +213,7 @@ discard block |
||
213 | 213 | */ |
214 | 214 | private function inputJson($data) |
215 | 215 | { |
216 | - return $data === null? $data : \json_encode($data); |
|
216 | + return $data === null ? $data : \json_encode($data); |
|
217 | 217 | } |
218 | 218 | |
219 | 219 | /** |
@@ -37,7 +37,7 @@ |
||
37 | 37 | */ |
38 | 38 | public function register() |
39 | 39 | { |
40 | - set_exception_handler([$this,'uncaughtException']); |
|
40 | + set_exception_handler([$this, 'uncaughtException']); |
|
41 | 41 | return $this; |
42 | 42 | } |
43 | 43 |
@@ -251,7 +251,7 @@ |
||
251 | 251 | protected static function createDefaultMiddleware(string $object, TableStruct $struct) |
252 | 252 | { |
253 | 253 | $reflectObject = new ReflectionClass($object); |
254 | - $classDoc = is_string($reflectObject->getDocComment())?$reflectObject->getDocComment():''; |
|
254 | + $classDoc = is_string($reflectObject->getDocComment()) ? $reflectObject->getDocComment() : ''; |
|
255 | 255 | if (\preg_match('/@field-(serialize|json)\s+(\w+)/i', $classDoc, $matchs)) { |
256 | 256 | return new TableStructMiddleware($object, $struct); |
257 | 257 | } |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | { |
39 | 39 | $this->object = $object; |
40 | 40 | $this->reflectObject = new ReflectionClass($object); |
41 | - $this->classDoc = is_string($this->reflectObject->getDocComment())?$this->reflectObject->getDocComment():''; |
|
41 | + $this->classDoc = is_string($this->reflectObject->getDocComment()) ? $this->reflectObject->getDocComment() : ''; |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | |
@@ -61,10 +61,10 @@ discard block |
||
61 | 61 | * @param string $classDoc |
62 | 62 | * @return array|null |
63 | 63 | */ |
64 | - public static function readClassDocField(string $classDoc):?array |
|
64 | + public static function readClassDocField(string $classDoc): ?array |
|
65 | 65 | { |
66 | 66 | if (preg_match_all('/^.+\s+\@field(?:\-(?:serialize|json))?\s+(\w+)\s+(\w+)(?:\((.+?)\))?(.*?)$/im', $classDoc, $match) > 0) { |
67 | - return is_array($match)?$match:null; |
|
67 | + return is_array($match) ? $match : null; |
|
68 | 68 | } |
69 | 69 | return null; |
70 | 70 | } |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | |
31 | 31 | public function __construct($file) |
32 | 32 | { |
33 | - $this->file = $file instanceof SplFileObject? $file : new SplFileObject($file); |
|
33 | + $this->file = $file instanceof SplFileObject ? $file : new SplFileObject($file); |
|
34 | 34 | $this->mime = MimeType::getMimeType($this->file->getExtension()); |
35 | 35 | } |
36 | 36 | |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | protected function sendMultipleRangePart(Response $response, array $range) |
122 | 122 | { |
123 | 123 | $response->write('Content-Type: '.$this->mime."\r\n"); |
124 | - $response->write('Content-Range: '.$this->getRangeHeader($range) ."\r\n\r\n"); |
|
124 | + $response->write('Content-Range: '.$this->getRangeHeader($range)."\r\n\r\n"); |
|
125 | 125 | } |
126 | 126 | |
127 | 127 | /** |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | * @param string $range |
181 | 181 | * @return array |
182 | 182 | */ |
183 | - protected function parseRange(string $range):?array |
|
183 | + protected function parseRange(string $range): ?array |
|
184 | 184 | { |
185 | 185 | $range = trim($range); |
186 | 186 | if (strrpos($range, '-') === strlen($range) - 1) { |
@@ -192,9 +192,9 @@ discard block |
||
192 | 192 | list($start, $end) = \explode('-', $range, 2); |
193 | 193 | $length = intval($end - $start); |
194 | 194 | if ($length <= 0) { |
195 | - return ['start' => intval($start) , 'end' => $this->file->getSize() - 1 ]; |
|
195 | + return ['start' => intval($start), 'end' => $this->file->getSize() - 1]; |
|
196 | 196 | } |
197 | - return ['start' => intval($start) , 'end' => intval($end) ]; |
|
197 | + return ['start' => intval($start), 'end' => intval($end)]; |
|
198 | 198 | } |
199 | 199 | return null; |
200 | 200 | } |