Skip to content

Commit 16924b6

Browse files
committed
[#.x] - adjusting tests; phpcs; docblocks; minor corrections
1 parent 33dff53 commit 16924b6

16 files changed

+103
-90
lines changed

src/Domain/Infrastructure/CommandBus/ContainerHandlerLocator.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,15 @@ public function resolve(CommandInterface $command): HandlerInterface
3535
{
3636
$commandClass = get_class($command);
3737

38+
/**
39+
* Phalcon\Api\Domain\Application\User\Command\UserGetCommand
40+
*
41+
* becomes
42+
*
43+
* Phalcon\Api\Domain\Application\User\Handler\UserGetHandler
44+
*
45+
* The location of files DOES matter
46+
*/
3847
$handlerClass = str_replace(
3948
'Command',
4049
'Handler',

src/Domain/Infrastructure/DataSource/Validation/ValidatorInterface.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@
1616
use Phalcon\Api\Domain\Infrastructure\CommandBus\CommandInterface;
1717

1818
/**
19-
* Validator contract. Accepts a DTO or input and returns a Result.
19+
* Validator contract. Accepts a Command and returns a Result.
2020
*/
2121
interface ValidatorInterface
2222
{
2323
/**
24-
* Validate a DTO or input structure.
24+
* Validate a Command object
2525
*
26-
* @param CommandInterface $command DTO or array
26+
* @param CommandInterface $command
2727
*
2828
* @return Result
2929
*/

src/Domain/Infrastructure/Enums/Container/AuthDefinitionsEnum.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ public function isShared(): bool
146146
}
147147

148148
/**
149-
* @param string $className
149+
* @param class-string $className
150150
*
151151
* @return TService
152152
*/

src/Domain/Infrastructure/Enums/Container/CommonDefinitionsEnum.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -138,10 +138,6 @@ public function definition(): array
138138

139139
public function isShared(): bool
140140
{
141-
return match ($this) {
142-
self::JWTToken,
143-
self::JWTTokenCache => false,
144-
default => true,
145-
};
141+
return true;
146142
}
147143
}

src/Domain/Infrastructure/Enums/Container/UserDefinitionsEnum.php

Lines changed: 43 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -106,56 +106,14 @@ public function definition(): array
106106
],
107107
],
108108
],
109-
self::UserPostHandler => [
110-
'className' => UserPostHandler::class,
111-
'arguments' => [
112-
[
113-
'type' => 'service',
114-
'name' => UserValidator::class,
115-
],
116-
[
117-
'type' => 'service',
118-
'name' => UserMapper::class,
119-
],
120-
[
121-
'type' => 'service',
122-
'name' => UserRepository::class,
123-
],
124-
[
125-
'type' => 'service',
126-
'name' => Registry::class,
127-
],
128-
[
129-
'type' => 'service',
130-
'name' => Security::class,
131-
],
132-
],
133-
],
134-
self::UserPutHandler => [
135-
'className' => UserPutHandler::class,
136-
'arguments' => [
137-
[
138-
'type' => 'service',
139-
'name' => UserValidatorUpdate::class,
140-
],
141-
[
142-
'type' => 'service',
143-
'name' => UserMapper::class,
144-
],
145-
[
146-
'type' => 'service',
147-
'name' => UserRepository::class,
148-
],
149-
[
150-
'type' => 'service',
151-
'name' => Registry::class,
152-
],
153-
[
154-
'type' => 'service',
155-
'name' => Security::class,
156-
],
157-
],
158-
],
109+
self::UserPostHandler => $this->getServicePutPost(
110+
UserPostHandler::class,
111+
UserValidator::class
112+
),
113+
self::UserPutHandler => $this->getServicePutPost(
114+
UserPutHandler::class,
115+
UserValidatorUpdate::class
116+
),
159117
self::UserMapper => [
160118
'className' => UserMapper::class,
161119
],
@@ -209,6 +167,41 @@ private function getService(string $className): array
209167
];
210168
}
211169

170+
/**
171+
* @param class-string $className
172+
* @param class-string $validatorName
173+
*
174+
* @return TService
175+
*/
176+
private function getServicePutPost(string $className, string $validatorName): array
177+
{
178+
return [
179+
'className' => $className,
180+
'arguments' => [
181+
[
182+
'type' => 'service',
183+
'name' => $validatorName,
184+
],
185+
[
186+
'type' => 'service',
187+
'name' => UserMapper::class,
188+
],
189+
[
190+
'type' => 'service',
191+
'name' => UserRepository::class,
192+
],
193+
[
194+
'type' => 'service',
195+
'name' => Registry::class,
196+
],
197+
[
198+
'type' => 'service',
199+
'name' => Security::class,
200+
],
201+
],
202+
];
203+
}
204+
212205
/**
213206
* @param class-string $className
214207
*

src/Domain/Infrastructure/Enums/Http/RoutesEnum.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ enum RoutesEnum: int
4444
*/
4545
public const EVENT_BEFORE = 'before';
4646
public const EVENT_FINISH = 'finish';
47-
public const GET = 'get';
48-
public const POST = 'post';
49-
public const PUT = 'put';
47+
public const GET = 'get';
48+
public const POST = 'post';
49+
public const PUT = 'put';
5050

5151
case authLoginPost = 11;
5252
case authLogoutPost = 12;

src/Domain/Infrastructure/Middleware/AbstractMiddleware.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ protected function halt(
8989
/** @var ResponseInterface $response */
9090
$response = $application->getSharedService(Container::RESPONSE);
9191
/** @var ResponderInterface $responder */
92-
$responder = $application->getService(JsonResponder::class);
92+
$responder = $application->getSharedService(JsonResponder::class);
9393

9494
$application->stop();
9595

src/Domain/Infrastructure/Middleware/HealthMiddleware.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
use Phalcon\Api\Domain\Infrastructure\Container;
1717
use Phalcon\Api\Domain\Infrastructure\Enums\Http\HttpCodesEnum;
1818
use Phalcon\Events\Exception as EventsException;
19-
use Phalcon\Http\Request;
19+
use Phalcon\Http\RequestInterface;
2020
use Phalcon\Http\Response\Exception;
2121
use Phalcon\Mvc\Micro;
2222

@@ -31,7 +31,7 @@ final class HealthMiddleware extends AbstractMiddleware
3131
*/
3232
public function call(Micro $application): bool
3333
{
34-
/** @var Request $request */
34+
/** @var RequestInterface $request */
3535
$request = $application->getSharedService(Container::REQUEST);
3636

3737
if (

src/Domain/Infrastructure/Middleware/ValidateTokenPresenceMiddleware.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
use Phalcon\Api\Domain\Infrastructure\Enums\Http\HttpCodesEnum;
1818
use Phalcon\Api\Domain\Infrastructure\Env\EnvManager;
1919
use Phalcon\Events\Exception as EventsException;
20-
use Phalcon\Http\Request;
20+
use Phalcon\Http\RequestInterface;
2121
use Phalcon\Http\Response\Exception;
2222
use Phalcon\Mvc\Micro;
2323

@@ -32,7 +32,7 @@ final class ValidateTokenPresenceMiddleware extends AbstractMiddleware
3232
*/
3333
public function call(Micro $application): bool
3434
{
35-
/** @var Request $request */
35+
/** @var RequestInterface $request */
3636
$request = $application->getSharedService(Container::REQUEST);
3737
/** @var EnvManager $env */
3838
$env = $application->getSharedService(EnvManager::class);

src/Domain/Infrastructure/Middleware/ValidateTokenStructureMiddleware.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
use Phalcon\Api\Domain\Infrastructure\Enums\Http\HttpCodesEnum;
2020
use Phalcon\Api\Domain\Infrastructure\Env\EnvManager;
2121
use Phalcon\Events\Exception as EventsException;
22-
use Phalcon\Http\Request;
22+
use Phalcon\Http\RequestInterface;
2323
use Phalcon\Http\Response\Exception;
2424
use Phalcon\Mvc\Micro;
2525
use Phalcon\Support\Registry;
@@ -35,7 +35,7 @@ final class ValidateTokenStructureMiddleware extends AbstractMiddleware
3535
*/
3636
public function call(Micro $application): bool
3737
{
38-
/** @var Request $request */
38+
/** @var RequestInterface $request */
3939
$request = $application->getSharedService(Container::REQUEST);
4040
/** @var EnvManager $env */
4141
$env = $application->getSharedService(EnvManager::class);

0 commit comments

Comments
 (0)