@@ -55,8 +55,7 @@ |
||
55 | 55 | * @package Platine\Framework\Auth\Entity |
56 | 56 | * @extends Entity<Role> |
57 | 57 | */ |
58 | -class Role extends Entity |
|
59 | -{ |
|
58 | +class Role extends Entity { |
|
60 | 59 | /** |
61 | 60 | * |
62 | 61 | * @param EntityMapperInterface<Role> $mapper |
@@ -55,8 +55,7 @@ |
||
55 | 55 | * @package Platine\Framework\Auth\Entity |
56 | 56 | * @extends Entity<Permission> |
57 | 57 | */ |
58 | -class Permission extends Entity |
|
59 | -{ |
|
58 | +class Permission extends Entity { |
|
60 | 59 | /** |
61 | 60 | * |
62 | 61 | * @param EntityMapperInterface<Permission> $mapper |
@@ -55,14 +55,12 @@ |
||
55 | 55 | * @package Platine\Framework\Audit\Model |
56 | 56 | * @extends Repository<Audit> |
57 | 57 | */ |
58 | -class AuditRepository extends Repository |
|
59 | -{ |
|
58 | +class AuditRepository extends Repository { |
|
60 | 59 | /** |
61 | 60 | * Create new instance |
62 | 61 | * @param EntityManager<Audit> $manager |
63 | 62 | */ |
64 | - public function __construct(EntityManager $manager) |
|
65 | - { |
|
63 | + public function __construct(EntityManager $manager) { |
|
66 | 64 | parent::__construct($manager, Audit::class); |
67 | 65 | } |
68 | 66 | } |
@@ -53,8 +53,7 @@ discard block |
||
53 | 53 | * @class SessionUser |
54 | 54 | * @package Platine\Framework\Audit |
55 | 55 | */ |
56 | -class SessionUser implements AuditUserInterface |
|
57 | -{ |
|
56 | +class SessionUser implements AuditUserInterface { |
|
58 | 57 | /** |
59 | 58 | * The Authentication instance |
60 | 59 | * @var AuthenticationInterface |
@@ -66,8 +65,7 @@ discard block |
||
66 | 65 | * Create new instance |
67 | 66 | * @param AuthenticationInterface $authentication |
68 | 67 | */ |
69 | - public function __construct(AuthenticationInterface $authentication) |
|
70 | - { |
|
68 | + public function __construct(AuthenticationInterface $authentication) { |
|
71 | 69 | $this->authentication = $authentication; |
72 | 70 | } |
73 | 71 |
@@ -51,8 +51,7 @@ |
||
51 | 51 | * @class AuditUserInterface |
52 | 52 | * @package Platine\Framework\Audit |
53 | 53 | */ |
54 | -interface AuditUserInterface |
|
55 | -{ |
|
54 | +interface AuditUserInterface { |
|
56 | 55 | /** |
57 | 56 | * Return the user id |
58 | 57 | * @return int |
@@ -53,8 +53,7 @@ discard block |
||
53 | 53 | * @class ApiUser |
54 | 54 | * @package Platine\Framework\Audit |
55 | 55 | */ |
56 | -class ApiUser implements AuditUserInterface |
|
57 | -{ |
|
56 | +class ApiUser implements AuditUserInterface { |
|
58 | 57 | /** |
59 | 58 | * The API Authentication instance |
60 | 59 | * @var ApiAuthenticationInterface |
@@ -66,8 +65,7 @@ discard block |
||
66 | 65 | * Create new instance |
67 | 66 | * @param ApiAuthenticationInterface $authentication |
68 | 67 | */ |
69 | - public function __construct(ApiAuthenticationInterface $authentication) |
|
70 | - { |
|
68 | + public function __construct(ApiAuthenticationInterface $authentication) { |
|
71 | 69 | $this->authentication = $authentication; |
72 | 70 | } |
73 | 71 |
@@ -168,7 +168,7 @@ |
||
168 | 168 | continue; |
169 | 169 | } |
170 | 170 | |
171 | - $value = preg_replace_callback('~\$\{(\w+)\}~', function ($m) { |
|
171 | + $value = preg_replace_callback('~\$\{(\w+)\}~', function($m) { |
|
172 | 172 | return (null === $ref = Env::get($m[1], null)) ? $m[0] : $ref; |
173 | 173 | }, $value); |
174 | 174 |
@@ -55,8 +55,7 @@ discard block |
||
55 | 55 | * @class Loader |
56 | 56 | * @package Platine\Framework\Env |
57 | 57 | */ |
58 | -class Loader |
|
59 | -{ |
|
58 | +class Loader { |
|
60 | 59 | /** |
61 | 60 | * Put the parsed key value pair into |
62 | 61 | * $_ENV super global. |
@@ -92,7 +91,7 @@ discard block |
||
92 | 91 | bool $overwrite = false, |
93 | 92 | int $mode = self::PUTENV |
94 | 93 | ): void { |
95 | - if (!is_file($file)) { |
|
94 | + if (!is_file($file)) { |
|
96 | 95 | throw new InvalidArgumentException(sprintf( |
97 | 96 | 'The [%s] file does not exist or is not readable', |
98 | 97 | $file |
@@ -104,7 +103,7 @@ discard block |
||
104 | 103 | $content = (string) preg_replace('/^\s*#/m', ';', $fileContent); |
105 | 104 | $parsed = parse_ini_string($content, false, INI_SCANNER_RAW); |
106 | 105 | |
107 | - if ($parsed === false) { |
|
106 | + if ($parsed === false) { |
|
108 | 107 | throw new RuntimeException(sprintf( |
109 | 108 | 'The [%s] file cannot be parsed due to malformed values', |
110 | 109 | $file |
@@ -127,9 +126,9 @@ discard block |
||
127 | 126 | int $mode |
128 | 127 | ): void { |
129 | 128 | $default = microtime(true); |
130 | - foreach ($vars as $key => $value) { |
|
129 | + foreach ($vars as $key => $value) { |
|
131 | 130 | // Skip if we already have value and cant override. |
132 | - if (!$overwrite && $default !== Env::get($key, $default)) { |
|
131 | + if (!$overwrite && $default !== Env::get($key, $default)) { |
|
133 | 132 | continue; |
134 | 133 | } |
135 | 134 | |
@@ -163,12 +162,12 @@ discard block |
||
163 | 162 | array $vars, |
164 | 163 | int $mode |
165 | 164 | ): void { |
166 | - foreach ($vars as $key => $value) { |
|
167 | - if (!$value || strpos($value, '${') === false) { |
|
165 | + foreach ($vars as $key => $value) { |
|
166 | + if (!$value || strpos($value, '${') === false) { |
|
168 | 167 | continue; |
169 | 168 | } |
170 | 169 | |
171 | - $value = preg_replace_callback('~\$\{(\w+)\}~', function ($m) { |
|
170 | + $value = preg_replace_callback('~\$\{(\w+)\}~', function ($m) { |
|
172 | 171 | return (null === $ref = Env::get($m[1], null)) ? $m[0] : $ref; |
173 | 172 | }, $value); |
174 | 173 | |
@@ -185,7 +184,7 @@ discard block |
||
185 | 184 | */ |
186 | 185 | protected function setValueEnv(string $key, string $value, int $mode): void |
187 | 186 | { |
188 | - if ($mode & self::ENV) { |
|
187 | + if ($mode & self::ENV) { |
|
189 | 188 | $_ENV[$key] = $value; |
190 | 189 | } |
191 | 190 | } |
@@ -199,7 +198,7 @@ discard block |
||
199 | 198 | */ |
200 | 199 | protected function setValueServer(string $key, string $value, int $mode): void |
201 | 200 | { |
202 | - if ($mode & self::SERVER) { |
|
201 | + if ($mode & self::SERVER) { |
|
203 | 202 | $_SERVER[$key] = $value; |
204 | 203 | } |
205 | 204 | } |
@@ -213,7 +212,7 @@ discard block |
||
213 | 212 | */ |
214 | 213 | protected function setValuePutenv(string $key, string $value, int $mode): void |
215 | 214 | { |
216 | - if ($mode & self::PUTENV) { |
|
215 | + if ($mode & self::PUTENV) { |
|
217 | 216 | putenv("$key=$value"); |
218 | 217 | } |
219 | 218 | } |
@@ -115,12 +115,12 @@ |
||
115 | 115 | $options = 0 |
116 | 116 | ) { |
117 | 117 | static $special = [ |
118 | - 'true' => true, |
|
119 | - 'TRUE' => true, |
|
120 | - 'false' => false, |
|
121 | - 'FALSE' => false, |
|
122 | - 'null' => null, |
|
123 | - 'NULL' => null, |
|
118 | + 'true' => true, |
|
119 | + 'TRUE' => true, |
|
120 | + 'false' => false, |
|
121 | + 'FALSE' => false, |
|
122 | + 'null' => null, |
|
123 | + 'NULL' => null, |
|
124 | 124 | ]; |
125 | 125 | |
126 | 126 | $valueResolved = static::resolveReference($value); |
@@ -148,7 +148,7 @@ |
||
148 | 148 | return $value; |
149 | 149 | } |
150 | 150 | |
151 | - $valueResolved = preg_replace_callback('~\$\{(\w+)\}~', function ($m) { |
|
151 | + $valueResolved = preg_replace_callback('~\$\{(\w+)\}~', function($m) { |
|
152 | 152 | return (null === $ref = static::get($m[1], null)) ? $m[0] : $ref; |
153 | 153 | }, $value); |
154 | 154 |
@@ -52,8 +52,7 @@ discard block |
||
52 | 52 | * @class Env |
53 | 53 | * @package Platine\Framework\Env |
54 | 54 | */ |
55 | -class Env |
|
56 | -{ |
|
55 | +class Env { |
|
57 | 56 | /** |
58 | 57 | * Get the environment variable by its key/name. |
59 | 58 | * @param string $key |
@@ -67,8 +66,8 @@ discard block |
||
67 | 66 | $default = null, |
68 | 67 | ?string $filter = null, |
69 | 68 | $options = 0 |
70 | - ) { |
|
71 | - if ($filter !== null) { |
|
69 | + ) { |
|
70 | + if ($filter !== null) { |
|
72 | 71 | $filterMaps = [ |
73 | 72 | 'bool' => FILTER_VALIDATE_BOOLEAN, |
74 | 73 | 'int' => FILTER_VALIDATE_INT, |
@@ -78,22 +77,22 @@ discard block |
||
78 | 77 | 'url' => FILTER_VALIDATE_URL, |
79 | 78 | ]; |
80 | 79 | |
81 | - if (isset($filterMaps[$filter])) { |
|
80 | + if (isset($filterMaps[$filter])) { |
|
82 | 81 | $filter = $filterMaps[$filter]; |
83 | - } else { |
|
82 | + } else { |
|
84 | 83 | $filter = null; |
85 | 84 | } |
86 | 85 | } |
87 | 86 | $value = getenv($key); |
88 | - if ($value !== false) { |
|
87 | + if ($value !== false) { |
|
89 | 88 | return static::prepareValue($value, $filter, $options); |
90 | 89 | } |
91 | 90 | |
92 | - if (isset($_ENV[$key])) { |
|
91 | + if (isset($_ENV[$key])) { |
|
93 | 92 | return static::prepareValue($_ENV[$key], $filter, $options); |
94 | 93 | } |
95 | 94 | |
96 | - if (isset($_SERVER[$key])) { |
|
95 | + if (isset($_SERVER[$key])) { |
|
97 | 96 | return static::prepareValue($_SERVER[$key], $filter, $options); |
98 | 97 | } |
99 | 98 | |
@@ -113,7 +112,7 @@ discard block |
||
113 | 112 | string $value, |
114 | 113 | ?int $filter = null, |
115 | 114 | $options = 0 |
116 | - ) { |
|
115 | + ) { |
|
117 | 116 | static $special = [ |
118 | 117 | 'true' => true, |
119 | 118 | 'TRUE' => true, |
@@ -126,11 +125,11 @@ discard block |
||
126 | 125 | $valueResolved = static::resolveReference($value); |
127 | 126 | |
128 | 127 | // strlen($valueResolved) < 6. |
129 | - if (!isset($valueResolved[5]) && array_key_exists($valueResolved, $special)) { |
|
128 | + if (!isset($valueResolved[5]) && array_key_exists($valueResolved, $special)) { |
|
130 | 129 | return $special[$value]; |
131 | 130 | } |
132 | 131 | |
133 | - if ($filter === null || !function_exists('filter_var')) { |
|
132 | + if ($filter === null || !function_exists('filter_var')) { |
|
134 | 133 | return $valueResolved; |
135 | 134 | } |
136 | 135 | |
@@ -144,15 +143,15 @@ discard block |
||
144 | 143 | */ |
145 | 144 | protected static function resolveReference(string $value): string |
146 | 145 | { |
147 | - if (!$value || strpos($value, '${') === false) { |
|
146 | + if (!$value || strpos($value, '${') === false) { |
|
148 | 147 | return $value; |
149 | 148 | } |
150 | 149 | |
151 | - $valueResolved = preg_replace_callback('~\$\{(\w+)\}~', function ($m) { |
|
150 | + $valueResolved = preg_replace_callback('~\$\{(\w+)\}~', function ($m) { |
|
152 | 151 | return (null === $ref = static::get($m[1], null)) ? $m[0] : $ref; |
153 | 152 | }, $value); |
154 | 153 | |
155 | - if ($valueResolved !== null) { |
|
154 | + if ($valueResolved !== null) { |
|
156 | 155 | return $valueResolved; |
157 | 156 | } |
158 | 157 |
@@ -53,8 +53,7 @@ discard block |
||
53 | 53 | * @class TokenOwner |
54 | 54 | * @package Platine\Framework\OAuth2\User |
55 | 55 | */ |
56 | -class TokenOwner implements TokenOwnerInterface |
|
57 | -{ |
|
56 | +class TokenOwner implements TokenOwnerInterface { |
|
58 | 57 | /** |
59 | 58 | * The owner id |
60 | 59 | * @var mixed |
@@ -65,16 +64,14 @@ discard block |
||
65 | 64 | * Create new instance |
66 | 65 | * @param mixed|null $id |
67 | 66 | */ |
68 | - public function __construct($id = null) |
|
69 | - { |
|
67 | + public function __construct($id = null) { |
|
70 | 68 | $this->id = $id; |
71 | 69 | } |
72 | 70 | |
73 | 71 | /** |
74 | 72 | * {@inheritdoc} |
75 | 73 | */ |
76 | - public function getOwnerId() |
|
77 | - { |
|
74 | + public function getOwnerId() { |
|
78 | 75 | return $this->id; |
79 | 76 | } |
80 | 77 | } |