-
-
Notifications
You must be signed in to change notification settings - Fork 1
Catching up with the tests video #6 #14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
5a2354b
[#.x] - added user endpoint in routes and fixed tests
niden 3fae00f
[#.x] - new input class
niden 31c252e
[#.x] - moved abstract test class
niden 3035432
[#.x] - new test migration class
niden a91d146
[#.x] - added user transport class
niden 127132e
[#.x] - registering services
niden 350a5a1
[#.x] - refactoring responders
niden 265f5a3
[#.x] - new user repository class
niden fd89a7c
[#.x] - refactored domain to accept input
niden 73a9b7f
[#.x] - added user get service
niden d26a743
[#.x] - test case refactoring and adjusting tests
niden 9244835
[#.x] - phpcs
niden cff4a1a
[#.x] - fixes from copilot
niden File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| <?php | ||
|
|
||
| /** | ||
| * This file is part of the Phalcon API. | ||
| * | ||
| * (c) Phalcon Team <team@phalcon.io> | ||
| * | ||
| * For the full copyright and license information, please view | ||
| * the LICENSE file that was distributed with this source code. | ||
| */ | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace Phalcon\Api\Domain\ADR\Domain; | ||
|
|
||
| use Phalcon\Http\Request; | ||
|
|
||
| /** | ||
| * @phpstan-import-type TRequestQuery from InputTypes | ||
| */ | ||
| final class Input implements InputInterface | ||
| { | ||
| /** | ||
| * @param Request $request | ||
| * | ||
| * @return TRequestQuery | ||
| */ | ||
| public function __invoke(Request $request): array | ||
| { | ||
| /** @var TRequestQuery $query */ | ||
| $query = $request->getQuery(); | ||
|
|
||
| return $query; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| <?php | ||
|
|
||
| /** | ||
| * This file is part of the Phalcon API. | ||
| * | ||
| * (c) Phalcon Team <team@phalcon.io> | ||
| * | ||
| * For the full copyright and license information, please view | ||
| * the LICENSE file that was distributed with this source code. | ||
| */ | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace Phalcon\Api\Domain\ADR\Domain; | ||
|
|
||
| use Phalcon\Http\Request; | ||
|
|
||
| /** | ||
| * @phpstan-import-type TRequestQuery from InputTypes | ||
| */ | ||
| interface InputInterface | ||
| { | ||
| /** | ||
| * @param Request $request | ||
| * | ||
| * @return TRequestQuery | ||
| */ | ||
| public function __invoke(Request $request): array; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| <?php | ||
|
|
||
| /** | ||
| * This file is part of the Phalcon API. | ||
| * | ||
| * (c) Phalcon Team <team@phalcon.io> | ||
| * | ||
| * For the full copyright and license information, please view | ||
| * the LICENSE file that was distributed with this source code. | ||
| */ | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace Phalcon\Api\Domain\ADR\Domain; | ||
|
|
||
| /** | ||
| * @phpstan-type THelloInput array{} | ||
| * @phpstan-type TUserInput array{ | ||
| * userId?: int | ||
| * } | ||
| * @phpstan-type TRequestQuery array<array-key, bool|int|string> | ||
| */ | ||
| final class InputTypes | ||
| { | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| <?php | ||
|
|
||
| /** | ||
| * This file is part of the Phalcon API. | ||
| * | ||
| * (c) Phalcon Team <team@phalcon.io> | ||
| * | ||
| * For the full copyright and license information, please view | ||
| * the LICENSE file that was distributed with this source code. | ||
| */ | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace Phalcon\Api\Domain\ADR\Responder; | ||
|
|
||
| /** | ||
| * @phpstan-type TResultItem array<array-key, bool|int|string> | ||
| * @phpstan-type TResult array{ | ||
| * result: array<array-key, bool|int|string|TResultItem> | ||
| * } | ||
| */ | ||
| final class ResponderTypes | ||
| { | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| <?php | ||
|
|
||
| /** | ||
| * This file is part of the Phalcon API. | ||
| * | ||
| * (c) Phalcon Team <team@phalcon.io> | ||
| * | ||
| * For the full copyright and license information, please view | ||
| * the LICENSE file that was distributed with this source code. | ||
| */ | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace Phalcon\Api\Domain\DataSource\User; | ||
|
|
||
| use Phalcon\DataMapper\Pdo\Connection; | ||
| use Phalcon\DataMapper\Query\Select; | ||
|
|
||
| /** | ||
| * @phpstan-import-type TUserRecord from UserTypes | ||
| */ | ||
| final class UserRepository | ||
| { | ||
| public function __construct( | ||
| private readonly Connection $connection, | ||
| ) { | ||
| } | ||
|
|
||
| /** | ||
| * @param int|string $userId | ||
| * | ||
| * @return UserTransport | ||
| */ | ||
| public function findById(int | string $userId): UserTransport | ||
| { | ||
| $result = []; | ||
| if (true !== empty($userId)) { | ||
| $select = Select::new($this->connection); | ||
|
|
||
| /** @var TUserRecord $result */ | ||
| $result = $select | ||
| ->from('co_users') | ||
| ->where('usr_id = ', $userId) | ||
| ->fetchOne() | ||
| ; | ||
| } | ||
|
|
||
| return new UserTransport($result); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| <?php | ||
|
|
||
| /** | ||
| * This file is part of the Phalcon API. | ||
| * | ||
| * (c) Phalcon Team <team@phalcon.io> | ||
| * | ||
| * For the full copyright and license information, please view | ||
| * the LICENSE file that was distributed with this source code. | ||
| */ | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace Phalcon\Api\Domain\DataSource\User; | ||
|
|
||
| use Phalcon\Api\Domain\Exceptions\InvalidConfigurationArgumentException; | ||
|
|
||
| /** | ||
| * @method int getId() | ||
| * @method int getStatus() | ||
| * @method string getUsername() | ||
| * @method string getPassword() | ||
| * | ||
| * @phpstan-import-type TUserRecord from UserTypes | ||
| * @phpstan-import-type TUserTransport from UserTypes | ||
| */ | ||
| final class UserTransport | ||
| { | ||
| /** @var TUserTransport */ | ||
| private array $store; | ||
|
|
||
| /** | ||
| * @param TUserRecord $input | ||
| */ | ||
| public function __construct(array $input) | ||
| { | ||
| $this->store = [ | ||
| 'id' => (int)($input['usr_id'] ?? 0), | ||
| 'status' => (int)($input['usr_status_flag'] ?? 0), | ||
| 'username' => (string)($input['usr_username'] ?? ''), | ||
| 'password' => (string)($input['usr_password'] ?? ''), | ||
| ]; | ||
| } | ||
|
|
||
| /** | ||
| * @param string $name | ||
| * @param array<mixed> $arguments | ||
| * | ||
| * @return int|string | ||
| */ | ||
| public function __call(string $name, array $arguments): int | string | ||
| { | ||
| return match ($name) { | ||
| 'getId' => $this->store['id'], | ||
| 'getStatus' => $this->store['status'], | ||
| 'getUsername' => $this->store['username'], | ||
| 'getPassword' => $this->store['password'], | ||
| default => throw new InvalidConfigurationArgumentException( | ||
| 'The ' . $name . ' method is not supported. [' | ||
| . json_encode($arguments) . ']', | ||
| ), | ||
| }; | ||
| } | ||
|
|
||
| public function isEmpty(): bool | ||
| { | ||
| return 0 === $this->store['id']; | ||
| } | ||
|
|
||
| /** | ||
| * @return array<int, TUserTransport> | ||
| */ | ||
| public function toArray(): array | ||
| { | ||
| return [$this->store['id'] => $this->store]; | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| <?php | ||
|
|
||
| /** | ||
| * This file is part of the Phalcon API. | ||
| * | ||
| * (c) Phalcon Team <team@phalcon.io> | ||
| * | ||
| * For the full copyright and license information, please view | ||
| * the LICENSE file that was distributed with this source code. | ||
| */ | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace Phalcon\Api\Domain\DataSource\User; | ||
|
|
||
| /** | ||
| * @phpstan-type TUserRecord array{}|array{ | ||
| * usr_id: int, | ||
| * usr_status_flag: int, | ||
| * usr_username: string, | ||
| * usr_password: string | ||
| * } | ||
| * | ||
| * @phpstan-type TUserTransport array{ | ||
| * id: int, | ||
| * status: int, | ||
| * username: string, | ||
| * password: string | ||
| * } | ||
| */ | ||
| final class UserTypes | ||
| { | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.