@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | * @param mixed $default |
21 | 21 | * @return string|null |
22 | 22 | */ |
23 | - public function get(string $key,mixed $default = null): string|null |
|
23 | + public function get(string $key, mixed $default = null): string | null |
|
24 | 24 | { |
25 | 25 | $value = $this->request->get($key); |
26 | 26 | if (is_null($value)) { |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | if (is_null($value)) { |
30 | 30 | $value = $this->getContentValue($key); |
31 | 31 | } |
32 | - if(is_null($value) || $value == ''){ |
|
32 | + if (is_null($value) || $value == '') { |
|
33 | 33 | return $default; |
34 | 34 | } |
35 | 35 | return $value; |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | * Magic method to get property of request |
54 | 54 | * @param string $key |
55 | 55 | */ |
56 | - public function __get(string $key): string|null |
|
56 | + public function __get(string $key): string | null |
|
57 | 57 | { |
58 | 58 | return $this->get($key); |
59 | 59 | } |
@@ -42,8 +42,9 @@ discard block |
||
42 | 42 | */ |
43 | 43 | private function getContentValue($key): mixed{ |
44 | 44 | if ($this->getContent() && \Safe\json_decode($this->getContent())) { |
45 | - if (isset(\Safe\json_decode($this->getContent())->$key)) |
|
46 | - return \Safe\json_decode($this->getContent())->$key; |
|
45 | + if (isset(\Safe\json_decode($this->getContent())->$key)) { |
|
46 | + return \Safe\json_decode($this->getContent())->$key; |
|
47 | + } |
|
47 | 48 | } |
48 | 49 | return null; |
49 | 50 | } |
@@ -65,8 +66,9 @@ discard block |
||
65 | 66 | */ |
66 | 67 | public function all() : array |
67 | 68 | { |
68 | - if ($this->getContent() && \Safe\json_decode($this->getContent())) |
|
69 | - return array_merge($this->request->all(), $this->query->all(), \Safe\json_decode($this->getContent(), true)); |
|
69 | + if ($this->getContent() && \Safe\json_decode($this->getContent())) { |
|
70 | + return array_merge($this->request->all(), $this->query->all(), \Safe\json_decode($this->getContent(), true)); |
|
71 | + } |
|
70 | 72 | |
71 | 73 | return array_merge($this->request->all(), $this->query->all()); |
72 | 74 | |
@@ -80,8 +82,9 @@ discard block |
||
80 | 82 | public function has(string $key) : bool |
81 | 83 | { |
82 | 84 | if ($this->getContent() && \Safe\json_decode($this->getContent())) { |
83 | - if (isset(\Safe\json_decode($this->getContent())->$key)) |
|
84 | - return true; |
|
85 | + if (isset(\Safe\json_decode($this->getContent())->$key)) { |
|
86 | + return true; |
|
87 | + } |
|
85 | 88 | } |
86 | 89 | if ($this->request->has($key) || $this->query->has($key)) { |
87 | 90 | return true; |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | * @param Symfony\Component\HttpFoundation\Session\Storage\SessionStorageInterface|null $storage |
52 | 52 | * @return \Scrawler\Http\Session |
53 | 53 | */ |
54 | - function session(Symfony\Component\HttpFoundation\Session\Storage\SessionStorageInterface|null $storage = null): \Scrawler\Http\Session |
|
54 | + function session(Symfony\Component\HttpFoundation\Session\Storage\SessionStorageInterface | null $storage = null): \Scrawler\Http\Session |
|
55 | 55 | { |
56 | 56 | // @codeCoverageIgnoreStart |
57 | 57 | if (class_exists('\Scrawler\App')) { |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | |
69 | 69 | } |
70 | 70 | |
71 | -if (! function_exists('redirect')) { |
|
71 | +if (!function_exists('redirect')) { |
|
72 | 72 | /** |
73 | 73 | * Redirect to a new url |
74 | 74 | * Optionally send data to add to flashbag |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | * @param array<mixed> $data |
78 | 78 | * @return Symfony\Component\HttpFoundation\RedirectResponse |
79 | 79 | */ |
80 | - function redirect(string $url, array $data=[]) |
|
80 | + function redirect(string $url, array $data = []) |
|
81 | 81 | { |
82 | 82 | if (!empty($data)) { |
83 | 83 | foreach ($data as $key=>$value) { |
@@ -30,9 +30,9 @@ discard block |
||
30 | 30 | public function __construct() |
31 | 31 | { |
32 | 32 | //@codeCoverageIgnoreStart |
33 | - if(function_exists('db')){ |
|
33 | + if (function_exists('db')) { |
|
34 | 34 | $this->db = db(); |
35 | - }else{ |
|
35 | + } else { |
|
36 | 36 | throw new \Exception("This adapter requires scrawler\database"); |
37 | 37 | } |
38 | 38 | //@codeCoverageIgnoreEnd |
@@ -79,13 +79,13 @@ discard block |
||
79 | 79 | |
80 | 80 | public function updateTimestamp(string $sessionId, string $data): bool |
81 | 81 | { |
82 | - $expiry = (int) \Safe\ini_get('session.gc_maxlifetime'); |
|
82 | + $expiry = (int) \Safe\ini_get('session.gc_maxlifetime'); |
|
83 | 83 | $session = $this->db->find('session') |
84 | 84 | ->where('sessionid LIKE ?') |
85 | 85 | ->setParameter(0, $sessionId) |
86 | 86 | ->first(); |
87 | 87 | |
88 | - if (!is_null($session)){ |
|
88 | + if (!is_null($session)) { |
|
89 | 89 | $session->set('session_expire', time() + $expiry); |
90 | 90 | $this->db->save($session); |
91 | 91 | } |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | return true; |
94 | 94 | } |
95 | 95 | |
96 | - public function gc(int $maxlifetime): int|false |
|
96 | + public function gc(int $maxlifetime): int | false |
|
97 | 97 | { |
98 | 98 | $this->gcCalled = true; |
99 | 99 | return 0; |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | //@codeCoverageIgnoreStart |
33 | 33 | if(function_exists('db')){ |
34 | 34 | $this->db = db(); |
35 | - }else{ |
|
35 | + } else{ |
|
36 | 36 | throw new \Exception("This adapter requires scrawler\database"); |
37 | 37 | } |
38 | 38 | //@codeCoverageIgnoreEnd |
@@ -72,8 +72,9 @@ discard block |
||
72 | 72 | ->where('sessionid LIKE ?') |
73 | 73 | ->setParameter(0, $sessionId) |
74 | 74 | ->first(); |
75 | - if (!is_null($session)) |
|
76 | - $this->db->delete($session); |
|
75 | + if (!is_null($session)) { |
|
76 | + $this->db->delete($session); |
|
77 | + } |
|
77 | 78 | return true; |
78 | 79 | } |
79 | 80 |
@@ -11,8 +11,8 @@ |
||
11 | 11 | |
12 | 12 | Class DatabaseAdapter extends NativeSessionStorage { |
13 | 13 | |
14 | - public function __construct(){ |
|
15 | - parent::__construct([],new DatabaseHandler); |
|
14 | + public function __construct() { |
|
15 | + parent::__construct([], new DatabaseHandler); |
|
16 | 16 | } |
17 | 17 | |
18 | 18 | } |
19 | 19 | \ No newline at end of file |
@@ -31,9 +31,9 @@ |
||
31 | 31 | * @param array<mixed> $headers |
32 | 32 | * @return Response |
33 | 33 | */ |
34 | - public function json(string|array $data,array $headers=[]): Response |
|
34 | + public function json(string | array $data, array $headers = []): Response |
|
35 | 35 | { |
36 | - if(is_array($data)){ |
|
36 | + if (is_array($data)) { |
|
37 | 37 | $data = \Safe\json_encode($data); |
38 | 38 | } |
39 | 39 | $this->setContent($data); |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | * @param string $key |
19 | 19 | * @param string $value |
20 | 20 | */ |
21 | - public function __set(string $key,string $value) : void |
|
21 | + public function __set(string $key, string $value) : void |
|
22 | 22 | { |
23 | 23 | $this->set($key, $value); |
24 | 24 | } |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | * @param string|null $message |
69 | 69 | * @return array<mixed>|null |
70 | 70 | */ |
71 | - public function flash(?string $type = null,string|null $message = null): ?array |
|
71 | + public function flash(?string $type = null, string | null $message = null): ?array |
|
72 | 72 | { |
73 | 73 | if (!is_null($message) && !is_null($type)) { |
74 | 74 | $this->getFlashBag()->add($type, $message); |