diff --git a/.github/workflows/codecov.yml b/.github/workflows/codecov.yml
new file mode 100644
index 0000000..56e0638
--- /dev/null
+++ b/.github/workflows/codecov.yml
@@ -0,0 +1,61 @@
+on:
+ - push
+
+name: Run Codecov checks
+
+jobs:
+ code-coverage:
+ name: Code Coverage
+
+ runs-on: ${{ matrix.os }}
+
+ strategy:
+ matrix:
+ os:
+ - ubuntu-latest
+
+ php:
+ - "8.1"
+ - "8.2"
+
+ steps:
+ - name: Checkout
+ uses: actions/checkout@v3
+
+ - name: Install PHP
+ uses: shivammathur/setup-php@v2
+ with:
+ php-version: "${{ matrix.php }}"
+ coverage: pcov
+ ini-values: assert.exception=1, zend.assertions=1, error_reporting=-1, log_errors_max_len=0, display_errors=On
+ tools: composer:v2, cs2pr
+
+ - name: Determine composer cache directory
+ run: echo "COMPOSER_CACHE_DIR=$(composer config cache-dir)" >> $GITHUB_ENV
+
+ - name: Cache dependencies installed with composer
+ uses: actions/cache@v3
+ with:
+ path: ${{ env.COMPOSER_CACHE_DIR }}
+ key: php${{ matrix.php }}-composer-${{ hashFiles('**/composer.json') }}
+ restore-keys: |
+ php${{ matrix.php }}-composer-
+
+ - name: Install dependencies with composer
+ run: composer install --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi
+
+ - name: Setup project
+ run: |
+ mv config/autoload/local.php.dist config/autoload/local.php
+ mv config/autoload/mail.local.php.dist config/autoload/mail.local.php
+ mv config/autoload/local.test.php.dist config/autoload/local.test.php
+
+ - name: Run unit tests
+ run: vendor/bin/phpunit --testsuite=UnitTests --testdox --colors=always --coverage-clover clover.xml
+ - name: Run functional tests
+ run: vendor/bin/phpunit --testsuite=FunctionalTests --testdox --colors=always --coverage-clover clover.xml
+
+ - name: Send code coverage report to Codecov.io
+ uses: codecov/codecov-action@v3
+ with:
+ token: ${{ secrets.CODECOV_TOKEN }}
diff --git a/.github/workflows/cs-tests.yml b/.github/workflows/cs-tests.yml
new file mode 100644
index 0000000..3da9965
--- /dev/null
+++ b/.github/workflows/cs-tests.yml
@@ -0,0 +1,46 @@
+on:
+ - push
+
+name: Run phpcs checks
+
+jobs:
+ mutation:
+ name: PHP ${{ matrix.php }}-${{ matrix.os }}
+
+ runs-on: ${{ matrix.os }}
+
+ strategy:
+ matrix:
+ os:
+ - ubuntu-latest
+
+ php:
+ - "8.1"
+ - "8.2"
+
+ steps:
+ - name: Checkout
+ uses: actions/checkout@v3
+
+ - name: Install PHP
+ uses: shivammathur/setup-php@v2
+ with:
+ php-version: "${{ matrix.php }}"
+ tools: composer:v2, cs2pr
+ coverage: none
+
+ - name: Determine composer cache directory
+ run: echo "COMPOSER_CACHE_DIR=$(composer config cache-dir)" >> $GITHUB_ENV
+
+ - name: Cache dependencies installed with composer
+ uses: actions/cache@v3
+ with:
+ path: ${{ env.COMPOSER_CACHE_DIR }}
+ key: php${{ matrix.php }}-composer-${{ hashFiles('**/composer.json') }}
+ restore-keys: |
+ php${{ matrix.php }}-composer-
+ - name: Install dependencies with composer
+ run: composer update --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi
+
+ - name: Run phpcs checks
+ run: vendor/bin/phpcs
diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml
index b79941d..39ee42c 100644
--- a/.github/workflows/run-tests.yml
+++ b/.github/workflows/run-tests.yml
@@ -1,5 +1,4 @@
on:
-# - pull_request
- push
name: Run PHPUnit tests
@@ -17,6 +16,7 @@ jobs:
php:
- "8.1"
+ - "8.2"
steps:
- name: Checkout
diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/static-analysis.yml
index 3c6b971..b863b6d 100644
--- a/.github/workflows/static-analysis.yml
+++ b/.github/workflows/static-analysis.yml
@@ -1,8 +1,7 @@
on:
-# - pull_request
- push
-name: static analysis
+name: Run static analysis
jobs:
mutation:
@@ -17,6 +16,7 @@ jobs:
php:
- "8.1"
+ - "8.2"
steps:
- name: Checkout
diff --git a/.gitignore b/.gitignore
index e6afb97..d4e57a3 100644
--- a/.gitignore
+++ b/.gitignore
@@ -38,3 +38,4 @@ composer.phar
composer.lock
.phpunit.result.cache
+.phpcs-cache
diff --git a/README.md b/README.md
index d7a0686..28bbf3d 100644
--- a/README.md
+++ b/README.md
@@ -3,16 +3,16 @@
Based on Enrico Zimuel's [Zend Expressive API - Skeleton example](https://github.com/ezimuel/zend-expressive-api), DotKernel API runs on [Laminas](https://github.com/laminas) and [Mezzio](https://github.com/mezzio) components and implements standards like PSR-3, PSR-4, PSR-7, PSR-11 and PSR-15.
![OSS Lifecycle](https://img.shields.io/osslifecycle/dotkernel/api)
+![PHP from Packagist (specify version)](https://img.shields.io/packagist/php-v/dotkernel/api/4.2.0)
[![GitHub issues](https://img.shields.io/github/issues/dotkernel/api)](https://github.com/dotkernel/api/issues)
[![GitHub forks](https://img.shields.io/github/forks/dotkernel/api)](https://github.com/dotkernel/api/network)
[![GitHub stars](https://img.shields.io/github/stars/dotkernel/api)](https://github.com/dotkernel/api/stargazers)
[![GitHub license](https://img.shields.io/github/license/dotkernel/api)](https://github.com/dotkernel/api/blob/4.0/LICENSE.md)
-![PHP from Packagist (specify version)](https://img.shields.io/packagist/php-v/dotkernel/api/4.0.x-dev)
-
[![Build Static](https://github.com/dotkernel/api/actions/workflows/static-analysis.yml/badge.svg?branch=4.0)](https://github.com/dotkernel/api/actions/workflows/static-analysis.yml)
[![Build Static](https://github.com/dotkernel/api/actions/workflows/run-tests.yml/badge.svg?branch=4.0)](https://github.com/dotkernel/api/actions/workflows/run-tests.yml)
+[![codecov](https://codecov.io/gh/dotkernel/api/graph/badge.svg?token=53FN78G5CK)](https://codecov.io/gh/dotkernel/api)
[![SymfonyInsight](https://insight.symfony.com/projects/7f9143cc-5e3c-4cfc-992c-377a001fde3e/big.svg)](https://insight.symfony.com/projects/7f9143cc-5e3c-4cfc-992c-377a001fde3e)
@@ -65,9 +65,6 @@ composer development-status
* duplicate `config/autoload/local.php.dist` as `config/autoload/local.php`
* duplicate `config/autoload/mail.local.php.dist` as `config/autoload/mail.local.php` <- if your API will send emails, make sure you fill in SMTP connection params
-Optional:
-* duplicate `phpcs.xml.dist` as `phpcs.xml`
-
### Step 5: Setup database
diff --git a/bin/clear-config-cache.php b/bin/clear-config-cache.php
index 2fcf36b..9e3a7af 100644
--- a/bin/clear-config-cache.php
+++ b/bin/clear-config-cache.php
@@ -1,12 +1,9 @@
[
- 'roles' => [
+ 'roles' => [
AdminRole::ROLE_SUPERUSER => [],
- AdminRole::ROLE_ADMIN => [AdminRole::ROLE_SUPERUSER],
- UserRole::ROLE_GUEST => [UserRole::ROLE_USER]
+ AdminRole::ROLE_ADMIN => [
+ AdminRole::ROLE_SUPERUSER,
+ ],
+ UserRole::ROLE_GUEST => [
+ UserRole::ROLE_USER,
+ ],
],
'permissions' => [
AdminRole::ROLE_SUPERUSER => [],
- AdminRole::ROLE_ADMIN => [
+ AdminRole::ROLE_ADMIN => [
'admin.my-account.update',
'admin.my-account.view',
'admin.create',
@@ -49,7 +53,7 @@
'error.report',
'home',
],
- UserRole::ROLE_USER => [
+ UserRole::ROLE_USER => [
'user.my-account.delete',
'user.my-account.update',
'user.my-account.view',
@@ -57,7 +61,7 @@
'user.my-avatar.delete',
'user.my-avatar.view',
],
- UserRole::ROLE_GUEST => [
+ UserRole::ROLE_GUEST => [
'account.activate.request',
'account.activate',
'account.register',
@@ -70,7 +74,7 @@
'error.report',
'home',
'user.create',
- ]
+ ],
],
- ]
+ ],
];
diff --git a/config/autoload/cli.global.php b/config/autoload/cli.global.php
index 8f3cddf..1f88428 100644
--- a/config/autoload/cli.global.php
+++ b/config/autoload/cli.global.php
@@ -9,18 +9,18 @@
use Dot\Cli\FileLockerInterface;
return [
- 'dot_cli' => [
- 'version' => '1.0.0',
- 'name' => 'DotKernel CLI',
+ 'dot_cli' => [
+ 'version' => '1.0.0',
+ 'name' => 'DotKernel CLI',
'commands' => [
- DemoCommand::getDefaultName() => DemoCommand::class,
- RouteListCommand::getDefaultName() => RouteListCommand::class,
- AdminCreateCommand::getDefaultName() => AdminCreateCommand::class,
+ DemoCommand::getDefaultName() => DemoCommand::class,
+ RouteListCommand::getDefaultName() => RouteListCommand::class,
+ AdminCreateCommand::getDefaultName() => AdminCreateCommand::class,
TokenGenerateCommand::getDefaultName() => TokenGenerateCommand::class,
- ]
+ ],
],
FileLockerInterface::class => [
'enabled' => true,
'dirPath' => getcwd() . '/data/lock',
- ]
+ ],
];
diff --git a/config/autoload/cors.local.php.dist b/config/autoload/cors.local.php.dist
index a252337..e789151 100644
--- a/config/autoload/cors.local.php.dist
+++ b/config/autoload/cors.local.php.dist
@@ -6,18 +6,22 @@ use Mezzio\Cors\Configuration\ConfigurationInterface;
return [
ConfigurationInterface::CONFIGURATION_IDENTIFIER => [
- 'allowed_origins' => [
+ 'allowed_origins' => [
/**
* Leaving this line here makes your application accessible by any origin.
*
* To restrict, replace this line with a list of origins that should have access to your application.
* Example: "domain1.com", "domain2.com"
*/
- ConfigurationInterface::ANY_ORIGIN
+ ConfigurationInterface::ANY_ORIGIN,
],
- 'allowed_headers' => ['Accept', 'Content-Type', 'Authorization'], // Custom headers
- 'allowed_max_age' => '600', // 10 minutes
+ 'allowed_headers' => [
+ 'Accept',
+ 'Content-Type',
+ 'Authorization',
+ ], // Custom headers
+ 'allowed_max_age' => '600', // 10 minutes
'credentials_allowed' => true, // Allow cookies
- 'exposed_headers' => [], // Tell client that the API will always return this header
+ 'exposed_headers' => [], // Tell client that the API will always return this header
],
];
diff --git a/config/autoload/dependencies.global.php b/config/autoload/dependencies.global.php
index 27f200b..e856f63 100644
--- a/config/autoload/dependencies.global.php
+++ b/config/autoload/dependencies.global.php
@@ -36,15 +36,15 @@
// Use 'aliases' to alias a service name to another service. The
// key is the alias name, the value is the service to which it points.
'aliases' => [
- AccessTokenRepositoryInterface::class => OAuthAccessTokenRepository::class,
- AuthCodeRepositoryInterface::class => OAuthAuthCodeRepository::class,
- ClientRepositoryInterface::class => OAuthClientRepository::class,
- RefreshTokenRepositoryInterface::class => OAuthRefreshTokenRepository::class,
- ScopeRepositoryInterface::class => OAuthScopeRepository::class,
- ErrorHandlerInterface::class => LogErrorHandler::class,
- Mezzio\Authentication\UserInterface::class => UserIdentity::class,
+ AccessTokenRepositoryInterface::class => OAuthAccessTokenRepository::class,
+ AuthCodeRepositoryInterface::class => OAuthAuthCodeRepository::class,
+ ClientRepositoryInterface::class => OAuthClientRepository::class,
+ RefreshTokenRepositoryInterface::class => OAuthRefreshTokenRepository::class,
+ ScopeRepositoryInterface::class => OAuthScopeRepository::class,
+ ErrorHandlerInterface::class => LogErrorHandler::class,
+ Mezzio\Authentication\UserInterface::class => UserIdentity::class,
Mezzio\Authorization\AuthorizationInterface::class => Mezzio\Authorization\Rbac\LaminasRbac::class,
- UserRepositoryInterface::class => UserRepository::class,
+ UserRepositoryInterface::class => UserRepository::class,
],
// Use 'invokables' for constructor-less services, or services that do
// not require arguments to the constructor. Map a service name to the
@@ -53,16 +53,16 @@
// Fully\Qualified\InterfaceName::class => Fully\Qualified\ClassName::class,
],
// Use 'factories' for services provided by callbacks/factory classes.
- 'factories' => [
- ExecuteCommand::class => CommandFactory::class,
+ 'factories' => [
+ ExecuteCommand::class => CommandFactory::class,
Mezzio\Middleware\ErrorResponseGenerator::class => ErrorResponseGeneratorFactory::class,
- OAuthAccessTokenRepository::class => OAuthAccessTokenRepositoryFactory::class,
- OAuthAuthCodeRepository::class => OAuthAuthCodeRepositoryFactory::class,
- OAuthClientRepository::class => OAuthClientRepositoryFactory::class,
- OAuthRefreshTokenRepository::class => OAuthRefreshTokenRepositoryFactory::class,
- OAuthScopeRepository::class => OAuthScopeRepositoryFactory::class,
- UserRepository::class => UserRepositoryFactory::class,
- UserIdentity::class => UserIdentityFactory::class,
+ OAuthAccessTokenRepository::class => OAuthAccessTokenRepositoryFactory::class,
+ OAuthAuthCodeRepository::class => OAuthAuthCodeRepositoryFactory::class,
+ OAuthClientRepository::class => OAuthClientRepositoryFactory::class,
+ OAuthRefreshTokenRepository::class => OAuthRefreshTokenRepositoryFactory::class,
+ OAuthScopeRepository::class => OAuthScopeRepositoryFactory::class,
+ UserRepository::class => UserRepositoryFactory::class,
+ UserIdentity::class => UserIdentityFactory::class,
],
],
];
diff --git a/config/autoload/development.local.php.dist b/config/autoload/development.local.php.dist
index 2110c4a..edd3efb 100644
--- a/config/autoload/development.local.php.dist
+++ b/config/autoload/development.local.php.dist
@@ -1,4 +1,5 @@
[
+ 'doctrine' => [
'connection' => [
'orm_default' => [
'doctrine_mapping_types' => [
- UuidBinaryType::NAME => 'binary',
+ UuidBinaryType::NAME => 'binary',
UuidBinaryOrderedTimeType::NAME => 'binary',
- ]
- ]
+ ],
+ ],
],
- 'driver' => [
- 'orm_default' => [
- 'class' => MappingDriverChain::class,
+ 'driver' => [
+ 'orm_default' => [
+ 'class' => MappingDriverChain::class,
'drivers' => [
- 'Api\\User\\Entity' => 'UserEntities',
+ 'Api\\User\\Entity' => 'UserEntities',
'Api\\Admin\\Entity' => 'AdminEntities',
- 'Api\\App\Entity' => 'AppEntities',
- ]
+ 'Api\\App\Entity' => 'AppEntities',
+ ],
],
'AdminEntities' => [
'class' => AnnotationDriver::class,
'cache' => 'array',
'paths' => __DIR__ . '/../../src/Admin/src/Entity',
],
- 'UserEntities' => [
+ 'UserEntities' => [
'class' => AnnotationDriver::class,
'cache' => 'array',
'paths' => __DIR__ . '/../../src/User/src/Entity',
],
- 'AppEntities' => [
+ 'AppEntities' => [
'class' => AnnotationDriver::class,
'cache' => 'array',
'paths' => __DIR__ . '/../../src/App/src/Entity',
- ]
+ ],
],
- 'types' => [
- UuidType::NAME => UuidType::class,
- UuidBinaryType::NAME => UuidBinaryType::class,
+ 'types' => [
+ UuidType::NAME => UuidType::class,
+ UuidBinaryType::NAME => UuidBinaryType::class,
UuidBinaryOrderedTimeType::NAME => UuidBinaryOrderedTimeType::class,
],
- 'cache' => [
+ 'cache' => [
PhpFileCache::class => [
- 'class' => PhpFileCache::class,
+ 'class' => PhpFileCache::class,
'directory' => getcwd() . '/data/cache/doctrine',
- ]
+ ],
],
- 'fixtures' => getcwd() . '/data/doctrine/fixtures',
+ 'fixtures' => getcwd() . '/data/doctrine/fixtures',
],
'resultCacheLifetime' => 3600,
];
diff --git a/config/autoload/error-handling.global.php b/config/autoload/error-handling.global.php
index 48dfe8c..77425f7 100644
--- a/config/autoload/error-handling.global.php
+++ b/config/autoload/error-handling.global.php
@@ -3,27 +3,26 @@
declare(strict_types=1);
use Api\App\Service\ErrorReportServiceInterface;
-use Laminas\Log\Logger;
use Laminas\Log\Formatter\Json;
+use Laminas\Log\Logger;
return [
'dot-errorhandler' => [
'loggerEnabled' => true,
- 'logger' => 'dot-log.default_logger'
+ 'logger' => 'dot-log.default_logger',
],
- 'dot_log' => [
+ 'dot_log' => [
'loggers' => [
'default_logger' => [
'writers' => [
'FileWriter' => [
- 'name' => 'stream',
+ 'name' => 'stream',
'priority' => Logger::ALERT,
- 'options' => [
- 'stream' => __DIR__ . '/../../log/error-log-{Y}-{m}-{d}.log',
- // explicitly log all messages
- 'filters' => [
+ 'options' => [
+ 'stream' => __DIR__ . '/../../log/error-log-{Y}-{m}-{d}.log',
+ 'filters' => [
'allMessages' => [
- 'name' => 'priority',
+ 'name' => 'priority',
'options' => [
'operator' => '>=',
'priority' => Logger::EMERG,
@@ -61,7 +60,7 @@
'path' => __DIR__ . '/../../log/error-report-endpoint-log.log',
/**
- * In order to be eligible for storing messages, Requests sent to the error reporting endpoint, must contain a header having:
+ * In order to store messages, requests sent to the error reporting endpoint, must contain a header having:
* - name: the value of \Api\App\Service\ErrorReportService::HEADER_NAME
* - value: one of the items in this array
*/
@@ -82,5 +81,5 @@
* 3. If you want to whitelist only specific IP addresses, add them to ip_whitelist.
*/
'ip_whitelist' => [],
- ]
+ ],
];
diff --git a/config/autoload/local.php.dist b/config/autoload/local.php.dist
index ea97e06..854ff23 100644
--- a/config/autoload/local.php.dist
+++ b/config/autoload/local.php.dist
@@ -1,10 +1,4 @@
[
- 'host' => 'localhost',
- 'dbname' => '',
- 'user' => '',
+ 'host' => 'localhost',
+ 'dbname' => '',
+ 'user' => '',
'password' => '',
- 'port' => 3306,
- 'driver' => 'pdo_mysql',
- 'charset' => 'utf8mb4',
- 'collate' => 'utf8mb4_general_ci'
- ]
+ 'port' => 3306,
+ 'driver' => 'pdo_mysql',
+ 'charset' => 'utf8mb4',
+ 'collate' => 'utf8mb4_general_ci',
+ ],
// you can add more database connections into this array
];
return [
'annotations_cache_dir' => getcwd() . '/data/cache/annotations',
- 'application' => [
+ 'application' => [
'name' => 'DotKernel API',
- 'url' => $baseUrl
+ 'url' => $baseUrl,
],
- 'authentication' => [
- 'private_key' => [
- 'key_or_path' => getcwd() . '/data/oauth/private.key',
- 'key_permissions_check' => false
+ 'authentication' => [
+ 'private_key' => [
+ 'key_or_path' => getcwd() . '/data/oauth/private.key',
+ 'key_permissions_check' => false,
],
- 'public_key' => [
- 'key_or_path' => getcwd() . '/data/oauth/public.key',
- 'key_permissions_check' => false
+ 'public_key' => [
+ 'key_or_path' => getcwd() . '/data/oauth/public.key',
+ 'key_permissions_check' => false,
],
- 'encryption_key' => require getcwd() . '/data/oauth/encryption.key',
+ 'encryption_key' => require getcwd() . '/data/oauth/encryption.key',
'access_token_expire' => 'P1D',
'refresh_token_expire' => 'P1M',
- 'auth_code_expire' => 'PT10M',
- 'invalid_credentials' => [
- 'error' => 'Invalid credentials.',
+ 'auth_code_expire' => 'PT10M',
+ 'invalid_credentials' => [
+ 'error' => 'Invalid credentials.',
'error_description' => 'Invalid credentials.',
- 'message' => 'Invalid credentials.',
- ]
+ 'message' => 'Invalid credentials.',
+ ],
],
- 'databases' => $databases,
- 'doctrine' => [
- 'connection' => [
+ 'databases' => $databases,
+ 'doctrine' => [
+ 'connection' => [
'orm_default' => [
'params' => $databases['default'],
- ]
+ ],
],
'configuration' => [
'orm_default' => [
// it is recommended to disable doctrine cache on development
// just comment any type of cache you don't want to be applied on development
- 'query_cache' => PhpFileCache::class,
- 'metadata_cache' => PhpFileCache::class,
- 'result_cache' => PhpFileCache::class,
+ 'query_cache' => PhpFileCache::class,
+ 'metadata_cache' => PhpFileCache::class,
+ 'result_cache' => PhpFileCache::class,
'entity_listener_resolver' => EntityListenerResolver::class,
],
],
],
- 'uploads' => [
+ 'uploads' => [
'user' => [
- 'url' => $baseUrl . '/uploads/user',
+ 'url' => $baseUrl . '/uploads/user',
'path' => realpath(__DIR__ . '/../../public/uploads/user'),
],
],
diff --git a/config/autoload/local.test.php.dist b/config/autoload/local.test.php.dist
index f18c364..6d0081e 100644
--- a/config/autoload/local.test.php.dist
+++ b/config/autoload/local.test.php.dist
@@ -1,4 +1,5 @@
[
- //the key is the mail service name, this is the default one, which does not extend any configuration
+// the key is the mail service name, this is the default one, which does not extend any configuration
'default' => [
- //tells which other mail service configuration to extend
+// tells which other mail service configuration to extend
'extends' => null,
-
/**
* the mail transport to use
* can be any class implementing Laminas\Mail\Transport\TransportInterface
@@ -30,111 +28,65 @@ return [
*
* defaults to sendmail
**/
-
'transport' => Smtp::class,
-
- // Uncomment the below line if you want to save a copy of all sent emails to a certain IMAP folder
- // Valid only if the Transport is SMTP
- // 'save_sent_message_folder' => ['INBOX.Sent'],
-
- //message configuration
+ /**
+ * Uncomment the below line if you want to save a copy of all sent emails to a certain IMAP folder.
+ * Valid only if the Transport is SMTP
+ */
+// 'save_sent_message_folder' => ['INBOX.Sent'],
+// message configuration
'message_options' => [
-
- //from email address of the email
- 'from' => '',
-
- //from name to be displayed instead of from address
- 'from_name' => 'DotKernel',
-
- //reply-to email address of the email
- 'reply_to' => '',
-
- //replyTo name to be displayed instead of the address
+ 'from' => '',
+ 'from_name' => 'DotKernel',
+ 'reply_to' => '',
'reply_to_name' => '',
-
- //destination email address as string or a list of email addresses
- 'to' => [],
-
- //copy destination addresses
- 'cc' => [],
-
- //hidden copy destination addresses
- 'bcc' => [],
-
- //email subject
- 'subject' => '',
-
- //body options - content can be plain text, HTML
- 'body' => [
+ 'to' => [],
+ 'cc' => [],
+ 'bcc' => [],
+ 'subject' => '',
+ 'body' => [
'content' => '',
-
'charset' => 'utf-8',
],
-
- //attachments config
- 'attachments' => [
+ 'attachments' => [
'files' => [],
-
- 'dir' => [
- 'iterate' => false,
- 'path' => 'data/mail/attachments',
+ 'dir' => [
+ 'iterate' => false,
+ 'path' => 'data/mail/attachments',
'recursive' => false,
- ]
+ ],
],
],
-
- //options that will be used only if Laminas\Mail\Transport\Smtp adapter is used
+// options that will be used only if Laminas\Mail\Transport\Smtp adapter is used
'smtp_options' => [
-
- //hostname or IP address of the mail server
- 'host' => 'smtp.gmail.com',
-
- //port of the mail server - 587 or 465 for secure connections
- 'port' => 587,
-
- //connection class used for authentication
- //the value can be one of smtp, plain, login or crammd5
- 'connection_class' => 'login',
-
+ 'host' => 'smtp.gmail.com',
+ 'port' => 587,
+ 'connection_class' => 'login',
'connection_config' => [
-
- //the smtp authentication identity
'username' => '',
-
- //the smtp authentication credential
'password' => '',
-
- //the encryption type to be used, ssl or tls
- //null should be used to disable SSL
- 'ssl' => 'tls',
- ]
+ 'ssl' => 'tls',
+ ],
],
-
- //file options that will be used only if the adapter is Laminas\Mail\Transport\File
- /*'file_options' => [
-
- //this is the folder where the file is going to be saved
- //default value is 'data/mail/output'
- 'path' => 'data/mail/output',
-
- //a callable that will get the Laminas\Mail\Transport\File object as an argument and should return the filename
- //if null is used, and empty callable will be used
- //'callback' => null,
- ],*/
-
- //listeners to register with the mail service, for mail events
+// file options that will be used only if the adapter is Laminas\Mail\Transport\File
+// 'file_options' => [
+// 'path' => 'data/mail/output',
+// //a callable that will get the Laminas\Mail\Transport\File object as an argument
+// //and should return the filename if null is used, and empty callable will be used
+// 'callback' => null,
+// ],
+// listeners to register with the mail service, for mail events
'event_listeners' => [
- //[
- //'type' => 'service or class name',
- //'priority' => 1
- //],
+// [
+// 'type' => 'service or class name',
+// 'priority' => 1,
+// ],
],
],
- // option to log the SENT emails
+// option to log the SENT emails
'log' => [
- 'sent' => getcwd() . '/log/mail/sent.log'
+ 'sent' => getcwd() . '/log/mail/sent.log',
],
-
/**
* You can define other mail services here, with the same structure as the default block
* you can even extend from the default block, and overwrite only the differences
diff --git a/config/autoload/mezzio-tooling-factories.global.php b/config/autoload/mezzio-tooling-factories.global.php
index 8953122..a81187f 100644
--- a/config/autoload/mezzio-tooling-factories.global.php
+++ b/config/autoload/mezzio-tooling-factories.global.php
@@ -1,4 +1,5 @@
true,
// Enable debugging; typically used to provide debugging information within templates.
- 'debug' => false,
-
+ 'debug' => false,
'mezzio' => [
// Provide templates for the error handling middleware to use when
// generating responses.
'error_handler' => [
- 'template_404' => 'error::404',
+ 'template_404' => 'error::404',
'template_error' => 'error::error',
],
],
diff --git a/config/autoload/response-header.global.php b/config/autoload/response-header.global.php
index 5573d2d..2381758 100644
--- a/config/autoload/response-header.global.php
+++ b/config/autoload/response-header.global.php
@@ -9,7 +9,7 @@
*/
'*' => [
'permissions-policy' => [
- 'value' => 'interest-cohort=()',
+ 'value' => 'interest-cohort=()',
'overwrite' => true,
],
],
@@ -23,5 +23,5 @@
// 'overwrite' => true,
// ]
// ],
- ]
+ ],
];
diff --git a/config/autoload/templates.global.php b/config/autoload/templates.global.php
index 273789a..411d20f 100644
--- a/config/autoload/templates.global.php
+++ b/config/autoload/templates.global.php
@@ -3,20 +3,20 @@
declare(strict_types=1);
return [
- 'debug' => false,
+ 'debug' => false,
'templates' => [
'extension' => 'html.twig',
],
- 'twig' => [
- 'assets_url' => '/',
- 'assets_version' => null,
- 'autoescape' => 'html',
- 'auto_reload' => true,
- 'cache_dir' => 'data/cache/twig',
- 'extensions' => [],
- 'globals' => [],
- 'optimizations' => -1,
- 'runtime_loaders' => [],
-// 'timezone' => '',
- ]
+ 'twig' => [
+ 'assets_url' => '/',
+ 'assets_version' => null,
+ 'autoescape' => 'html',
+ 'auto_reload' => true,
+ 'cache_dir' => 'data/cache/twig',
+ 'extensions' => [],
+ 'globals' => [],
+ 'optimizations' => -1,
+ 'runtime_loaders' => [],
+// 'timezone' => '',
+ ],
];
diff --git a/config/container.php b/config/container.php
index 570c6c4..16a9e05 100644
--- a/config/container.php
+++ b/config/container.php
@@ -7,7 +7,7 @@
// Load configuration
$config = require 'config/config.php';
-$dependencies = $config['dependencies'];
+$dependencies = $config['dependencies'];
$dependencies['services']['config'] = $config;
// Build container
diff --git a/config/development.config.php.dist b/config/development.config.php.dist
index 348da3b..94b06d2 100644
--- a/config/development.config.php.dist
+++ b/config/development.config.php.dist
@@ -1,4 +1,5 @@
true,
+ 'debug' => true,
ConfigAggregator::ENABLE_CACHE => false,
];
diff --git a/config/migrations.php b/config/migrations.php
index c264a63..2588890 100644
--- a/config/migrations.php
+++ b/config/migrations.php
@@ -3,16 +3,16 @@
declare(strict_types=1);
return [
- 'table_storage' => [
- 'table_name' => 'doctrine_migration_versions',
- 'version_column_name' => 'version',
- 'version_column_length' => 1024,
- 'executed_at_column_name' => 'executed_at',
+ 'table_storage' => [
+ 'table_name' => 'doctrine_migration_versions',
+ 'version_column_name' => 'version',
+ 'version_column_length' => 1024,
+ 'executed_at_column_name' => 'executed_at',
'execution_time_column_name' => 'execution_time',
],
- 'migrations_paths' => [
+ 'migrations_paths' => [
'Api\Migrations' => 'data/doctrine/migrations',
],
- 'all_or_nothing' => true,
+ 'all_or_nothing' => true,
'check_database_platform' => true,
];
diff --git a/config/pipeline.php b/config/pipeline.php
index 27cc60a..358e320 100644
--- a/config/pipeline.php
+++ b/config/pipeline.php
@@ -7,8 +7,8 @@
use Api\App\Middleware\AuthorizationMiddleware;
use Dot\ErrorHandler\ErrorHandlerInterface;
use Dot\ResponseHeader\Middleware\ResponseHeaderMiddleware;
-use Mezzio\Cors\Middleware\CorsMiddleware;
use Mezzio\Application;
+use Mezzio\Cors\Middleware\CorsMiddleware;
use Mezzio\Helper\BodyParams\BodyParamsMiddleware;
use Mezzio\Helper\ServerUrlMiddleware;
use Mezzio\Helper\UrlHelperMiddleware;
@@ -18,9 +18,6 @@
use Mezzio\Router\Middleware\MethodNotAllowedMiddleware;
use Mezzio\Router\Middleware\RouteMiddleware;
-/**
- * Setup middleware pipeline:
- */
return function (Application $app): void {
// The error handler should be the first (most outer) middleware to catch
// all Exceptions.
diff --git a/config/routes.php b/config/routes.php
index da4dd38..406bcdc 100644
--- a/config/routes.php
+++ b/config/routes.php
@@ -2,9 +2,9 @@
declare(strict_types=1);
-use Psr\Container\ContainerInterface;
use Mezzio\Application;
use Mezzio\MiddlewareFactory;
+use Psr\Container\ContainerInterface;
return function (Application $app, MiddlewareFactory $factory, ContainerInterface $container): void {
};
diff --git a/phpcs.xml b/phpcs.xml
new file mode 100644
index 0000000..fa6e19d
--- /dev/null
+++ b/phpcs.xml
@@ -0,0 +1,23 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+ bin
+ config
+ public
+ src
+ test
+
+
+
+
diff --git a/phpcs.xml.dist b/phpcs.xml.dist
deleted file mode 100644
index e66f5f5..0000000
--- a/phpcs.xml.dist
+++ /dev/null
@@ -1,20 +0,0 @@
-
-
- Mezzio Skeleton coding standard
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- src
-
diff --git a/phpunit.xml b/phpunit.xml
index 888f62e..6ac1fbc 100644
--- a/phpunit.xml
+++ b/phpunit.xml
@@ -5,10 +5,11 @@
colors="true">
- ./tests/AppTest/Unit
+ ./test/Unit
- ./tests/AppTest/Functional
+ ./test/Functional
+ ./test/Functional/AbstractFunctionalTest.php
diff --git a/psalm-baseline.xml b/psalm-baseline.xml
new file mode 100644
index 0000000..9f636fd
--- /dev/null
+++ b/psalm-baseline.xml
@@ -0,0 +1,30 @@
+
+
+
+
+ getSecret
+ getSecret
+
+
+
+
+ matching
+ matching
+
+
+
+
+ orX
+
+
+
+
+ matching
+
+
+
+
+ matching
+
+
+
diff --git a/psalm.xml b/psalm.xml
index 3e4e3d0..ed4c186 100644
--- a/psalm.xml
+++ b/psalm.xml
@@ -1,11 +1,13 @@
+ errorLevel="4"
+ resolveFromConfigFile="true"
+ findUnusedCode="false"
+ findUnusedBaselineEntry="true"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns="https://getpsalm.org/schema/config"
+ xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
+ errorBaseline="psalm-baseline.xml">
diff --git a/public/index.php b/public/index.php
index b604ce3..d8ace78 100644
--- a/public/index.php
+++ b/public/index.php
@@ -2,8 +2,9 @@
declare(strict_types=1);
-use Psr\Container\ContainerInterface;
use Mezzio\Application;
+use Mezzio\MiddlewareFactory;
+use Psr\Container\ContainerInterface;
// Delegate static file requests back to the PHP built-in webserver
if (PHP_SAPI === 'cli-server' && $_SERVER['SCRIPT_FILENAME'] !== __FILE__) {
@@ -21,8 +22,8 @@
$container = require 'config/container.php';
/** @var Application $app */
- $app = $container->get(Application::class);
- $factory = $container->get(\Mezzio\MiddlewareFactory::class);
+ $app = $container->get(Application::class);
+ $factory = $container->get(MiddlewareFactory::class);
// Execute programmatic/declarative middleware pipeline and routing
// configuration statements
diff --git a/src/Admin/src/Collection/AdminCollection.php b/src/Admin/src/Collection/AdminCollection.php
index 2ab5dcf..f23e56e 100644
--- a/src/Admin/src/Collection/AdminCollection.php
+++ b/src/Admin/src/Collection/AdminCollection.php
@@ -7,4 +7,5 @@
use Api\App\Collection\ResourceCollection;
class AdminCollection extends ResourceCollection
-{}
+{
+}
diff --git a/src/Admin/src/Collection/AdminRoleCollection.php b/src/Admin/src/Collection/AdminRoleCollection.php
index 6430031..4a42eab 100644
--- a/src/Admin/src/Collection/AdminRoleCollection.php
+++ b/src/Admin/src/Collection/AdminRoleCollection.php
@@ -7,4 +7,5 @@
use Api\App\Collection\ResourceCollection;
class AdminRoleCollection extends ResourceCollection
-{}
+{
+}
diff --git a/src/Admin/src/Command/AdminCreateCommand.php b/src/Admin/src/Command/AdminCreateCommand.php
index afa1544..0d277ac 100644
--- a/src/Admin/src/Command/AdminCreateCommand.php
+++ b/src/Admin/src/Command/AdminCreateCommand.php
@@ -15,8 +15,14 @@
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
+use function implode;
+use function sprintf;
+
+use const PHP_EOL;
+
class AdminCreateCommand extends Command
{
+ /** @var string $defaultName */
protected static $defaultName = 'admin:create';
public function __construct(
@@ -37,8 +43,7 @@ protected function configure(): void
->addOption('identity', 'i', InputOption::VALUE_REQUIRED, 'Admin identity')
->addOption('password', 'p', InputOption::VALUE_REQUIRED, 'Admin password')
->addOption('firstName', 'f', InputOption::VALUE_REQUIRED, 'Admin first name')
- ->addOption('lastName', 'l', InputOption::VALUE_REQUIRED, 'Admin last name')
- ;
+ ->addOption('lastName', 'l', InputOption::VALUE_REQUIRED, 'Admin last name');
}
/**
@@ -47,7 +52,7 @@ protected function configure(): void
protected function execute(InputInterface $input, OutputInterface $output): int
{
$inputFilter = (new CreateAdminInputFilter())->setData($this->getData($input));
- if (!$inputFilter->isValid()) {
+ if (! $inputFilter->isValid()) {
$messages = [];
foreach ($inputFilter->getMessages() as $field => $errors) {
foreach ($errors as $error) {
@@ -71,21 +76,21 @@ protected function execute(InputInterface $input, OutputInterface $output): int
private function getData(InputInterface $input): array
{
$role = $this->adminRoleService->findOneBy(['name' => AdminRole::ROLE_ADMIN]);
- if (!($role instanceof AdminRole)) {
+ if (! $role instanceof AdminRole) {
throw new Exception(
sprintf(Message::ADMIN_ROLE_MISSING, AdminRole::ROLE_ADMIN)
);
}
- return [
- 'identity' => $input->getOption('identity'),
- 'password' => $input->getOption('password'),
+ return [
+ 'identity' => $input->getOption('identity'),
+ 'password' => $input->getOption('password'),
'passwordConfirm' => $input->getOption('password'),
- 'firstName' => $input->getOption('firstName'),
- 'lastName' => $input->getOption('lastName'),
- 'roles' => [
- ['uuid' => $role->getUuid()->toString()]
- ]
+ 'firstName' => $input->getOption('firstName'),
+ 'lastName' => $input->getOption('lastName'),
+ 'roles' => [
+ ['uuid' => $role->getUuid()->toString()],
+ ],
];
}
}
diff --git a/src/Admin/src/ConfigProvider.php b/src/Admin/src/ConfigProvider.php
index 08e29d8..7ed44e6 100644
--- a/src/Admin/src/ConfigProvider.php
+++ b/src/Admin/src/ConfigProvider.php
@@ -29,7 +29,7 @@ class ConfigProvider
public function __invoke(): array
{
return [
- 'dependencies' => $this->getDependencies(),
+ 'dependencies' => $this->getDependencies(),
MetadataMap::class => $this->getHalConfig(),
];
}
@@ -38,17 +38,17 @@ public function getDependencies(): array
{
return [
'factories' => [
- AdminHandler::class => AnnotatedServiceFactory::class,
+ AdminHandler::class => AnnotatedServiceFactory::class,
AdminAccountHandler::class => AnnotatedServiceFactory::class,
- AdminRoleHandler::class => AnnotatedServiceFactory::class,
- AdminService::class => AnnotatedServiceFactory::class,
- AdminRoleService::class => AnnotatedServiceFactory::class,
- AdminCreateCommand::class => AdminCreateCommandFactory::class,
- AdminRepository::class => AnnotatedRepositoryFactory::class,
+ AdminRoleHandler::class => AnnotatedServiceFactory::class,
+ AdminService::class => AnnotatedServiceFactory::class,
+ AdminRoleService::class => AnnotatedServiceFactory::class,
+ AdminCreateCommand::class => AdminCreateCommandFactory::class,
+ AdminRepository::class => AnnotatedRepositoryFactory::class,
AdminRoleRepository::class => AnnotatedRepositoryFactory::class,
],
- 'aliases' => [
- AdminServiceInterface::class => AdminService::class,
+ 'aliases' => [
+ AdminServiceInterface::class => AdminService::class,
AdminRoleServiceInterface::class => AdminRoleService::class,
],
];
diff --git a/src/Admin/src/Entity/Admin.php b/src/Admin/src/Entity/Admin.php
index 0575d8c..52499f1 100644
--- a/src/Admin/src/Entity/Admin.php
+++ b/src/Admin/src/Entity/Admin.php
@@ -14,46 +14,34 @@
use League\OAuth2\Server\Entities\UserEntityInterface;
/**
- * Class Admin
* @ORM\Entity(repositoryClass="Api\Admin\Repository\AdminRepository")
* @ORM\Table(name="admin")
* @ORM\HasLifecycleCallbacks()
- * @package Api\Admin\Entity
*/
class Admin extends AbstractEntity implements UserEntityInterface
{
use PasswordTrait;
- public const STATUS_ACTIVE = 'active';
+ public const STATUS_ACTIVE = 'active';
public const STATUS_INACTIVE = 'inactive';
- public const STATUSES = [
+ public const STATUSES = [
self::STATUS_ACTIVE,
- self::STATUS_INACTIVE
+ self::STATUS_INACTIVE,
];
- /**
- * @ORM\Column(name="identity", type="string", length=100, unique=true)
- */
+ /** @ORM\Column(name="identity", type="string", length=100, unique=true) */
protected string $identity;
- /**
- * @ORM\Column(name="firstName", type="string", length=255)
- */
+ /** @ORM\Column(name="firstName", type="string", length=255) */
protected string $firstName;
- /**
- * @ORM\Column(name="lastName", type="string", length=255)
- */
+ /** @ORM\Column(name="lastName", type="string", length=255) */
protected string $lastName;
- /**
- * @ORM\Column(name="password", type="string", length=100)
- */
+ /** @ORM\Column(name="password", type="string", length=100) */
protected string $password;
- /**
- * @ORM\Column(name="status", type="string", length=20)
- */
+ /** @ORM\Column(name="status", type="string", length=20) */
protected string $status = self::STATUS_ACTIVE;
/**
@@ -79,16 +67,16 @@ public function __construct()
public function getArrayCopy(): array
{
return [
- 'uuid' => $this->getUuid()->toString(),
- 'identity' => $this->getIdentity(),
+ 'uuid' => $this->getUuid()->toString(),
+ 'identity' => $this->getIdentity(),
'firstName' => $this->getFirstName(),
- 'lastName' => $this->getLastName(),
- 'status' => $this->getStatus(),
- 'roles' => $this->getRoles()->map(function (AdminRole $role) {
- return $role->getArrayCopy();
+ 'lastName' => $this->getLastName(),
+ 'status' => $this->getStatus(),
+ 'roles' => $this->getRoles()->map(function (AdminRole $role) {
+ return $role->getArrayCopy();
})->toArray(),
- 'created' => $this->getCreated(),
- 'updated' => $this->getUpdated()
+ 'created' => $this->getCreated(),
+ 'updated' => $this->getUpdated(),
];
}
@@ -166,7 +154,7 @@ public function setRoles(ArrayCollection $roles): self
public function addRole(RoleInterface $role): self
{
- if (!$this->roles->contains($role)) {
+ if (! $this->roles->contains($role)) {
$this->roles->add($role);
}
@@ -175,7 +163,7 @@ public function addRole(RoleInterface $role): self
public function removeRole(RoleInterface $role): self
{
- if (!$this->roles->contains($role)) {
+ if (! $this->roles->contains($role)) {
$this->roles->removeElement($role);
}
diff --git a/src/Admin/src/Entity/AdminRole.php b/src/Admin/src/Entity/AdminRole.php
index 8422024..52a2965 100644
--- a/src/Admin/src/Entity/AdminRole.php
+++ b/src/Admin/src/Entity/AdminRole.php
@@ -9,24 +9,20 @@
use Doctrine\ORM\Mapping as ORM;
/**
- * Class AdminRole
* @ORM\Entity(repositoryClass="Api\Admin\Repository\AdminRoleRepository")
* @ORM\Table(name="admin_role")
* @ORM\HasLifecycleCallbacks()
- * @package Api\Admin\Entity
*/
class AdminRole extends AbstractEntity implements RoleInterface
{
- public const ROLE_ADMIN = 'admin';
+ public const ROLE_ADMIN = 'admin';
public const ROLE_SUPERUSER = 'superuser';
- public const ROLES = [
+ public const ROLES = [
self::ROLE_ADMIN,
- self::ROLE_SUPERUSER
+ self::ROLE_SUPERUSER,
];
- /**
- * @ORM\Column(name="name", type="string", length=30, unique=true)
- */
+ /** @ORM\Column(name="name", type="string", length=30, unique=true) */
protected string $name;
public function getName(): string
diff --git a/src/Admin/src/Handler/AdminAccountHandler.php b/src/Admin/src/Handler/AdminAccountHandler.php
index da95b58..a69d1d0 100644
--- a/src/Admin/src/Handler/AdminAccountHandler.php
+++ b/src/Admin/src/Handler/AdminAccountHandler.php
@@ -31,7 +31,8 @@ public function __construct(
protected HalResponseFactory $responseFactory,
protected ResourceGenerator $resourceGenerator,
protected AdminServiceInterface $adminService
- ) {}
+ ) {
+ }
public function get(ServerRequestInterface $request): ResponseInterface
{
@@ -44,7 +45,7 @@ public function get(ServerRequestInterface $request): ResponseInterface
public function patch(ServerRequestInterface $request): ResponseInterface
{
$inputFilter = (new UpdateAdminInputFilter())->setData($request->getParsedBody());
- if (!$inputFilter->isValid()) {
+ if (! $inputFilter->isValid()) {
return $this->errorResponse($inputFilter->getMessages());
}
diff --git a/src/Admin/src/Handler/AdminHandler.php b/src/Admin/src/Handler/AdminHandler.php
index dfa337e..75f9c36 100644
--- a/src/Admin/src/Handler/AdminHandler.php
+++ b/src/Admin/src/Handler/AdminHandler.php
@@ -18,6 +18,8 @@
use Psr\Http\Server\RequestHandlerInterface;
use Throwable;
+use function sprintf;
+
class AdminHandler implements RequestHandlerInterface
{
use ResponseTrait;
@@ -33,14 +35,15 @@ public function __construct(
protected HalResponseFactory $responseFactory,
protected ResourceGenerator $resourceGenerator,
protected AdminServiceInterface $adminService
- ) {}
+ ) {
+ }
public function delete(ServerRequestInterface $request): ResponseInterface
{
try {
- $uuid = $request->getAttribute('uuid');
+ $uuid = $request->getAttribute('uuid');
$admin = $this->adminService->findOneBy(['uuid' => $uuid]);
- if (!$admin instanceof Admin) {
+ if (! $admin instanceof Admin) {
return $this->notFoundResponse(sprintf(Message::NOT_FOUND_BY_UUID, 'admin', $uuid));
}
@@ -56,7 +59,7 @@ public function get(ServerRequestInterface $request): ResponseInterface
{
try {
$uuid = $request->getAttribute('uuid');
- if (!empty($uuid)) {
+ if (! empty($uuid)) {
return $this->view($request, $uuid);
}
@@ -69,14 +72,14 @@ public function get(ServerRequestInterface $request): ResponseInterface
public function patch(ServerRequestInterface $request): ResponseInterface
{
$inputFilter = (new UpdateAdminInputFilter())->setData($request->getParsedBody());
- if (!$inputFilter->isValid()) {
+ if (! $inputFilter->isValid()) {
return $this->errorResponse($inputFilter->getMessages());
}
try {
- $uuid = $request->getAttribute('uuid');
+ $uuid = $request->getAttribute('uuid');
$admin = $this->adminService->findOneBy(['uuid' => $uuid]);
- if (!$admin instanceof Admin) {
+ if (! $admin instanceof Admin) {
return $this->notFoundResponse(sprintf(Message::NOT_FOUND_BY_UUID, 'admin', $uuid));
}
@@ -91,7 +94,7 @@ public function patch(ServerRequestInterface $request): ResponseInterface
public function post(ServerRequestInterface $request): ResponseInterface
{
$inputFilter = (new CreateAdminInputFilter())->setData($request->getParsedBody());
- if (!$inputFilter->isValid()) {
+ if (! $inputFilter->isValid()) {
return $this->errorResponse($inputFilter->getMessages());
}
@@ -112,7 +115,7 @@ private function list(ServerRequestInterface $request): ResponseInterface
private function view(ServerRequestInterface $request, string $uuid): ResponseInterface
{
$admin = $this->adminService->findOneBy(['uuid' => $uuid]);
- if (!$admin instanceof Admin) {
+ if (! $admin instanceof Admin) {
return $this->notFoundResponse(sprintf(Message::NOT_FOUND_BY_UUID, 'admin', $uuid));
}
diff --git a/src/Admin/src/Handler/AdminRoleHandler.php b/src/Admin/src/Handler/AdminRoleHandler.php
index 0a54c56..9773761 100644
--- a/src/Admin/src/Handler/AdminRoleHandler.php
+++ b/src/Admin/src/Handler/AdminRoleHandler.php
@@ -16,6 +16,8 @@
use Psr\Http\Server\RequestHandlerInterface;
use Throwable;
+use function sprintf;
+
class AdminRoleHandler implements RequestHandlerInterface
{
use ResponseTrait;
@@ -31,13 +33,14 @@ public function __construct(
protected HalResponseFactory $responseFactory,
protected ResourceGenerator $resourceGenerator,
protected AdminRoleServiceInterface $roleService
- ) {}
+ ) {
+ }
public function get(ServerRequestInterface $request): ResponseInterface
{
try {
$uuid = $request->getAttribute('uuid');
- if (!empty($uuid)) {
+ if (! empty($uuid)) {
return $this->view($request, $uuid);
}
@@ -58,7 +61,7 @@ private function list(ServerRequestInterface $request): ResponseInterface
private function view(ServerRequestInterface $request, string $uuid): ResponseInterface
{
$role = $this->roleService->findOneBy(['uuid' => $uuid]);
- if (!$role instanceof AdminRole) {
+ if (! $role instanceof AdminRole) {
return $this->notFoundResponse(sprintf(Message::NOT_FOUND_BY_UUID, 'role', $uuid));
}
diff --git a/src/Admin/src/InputFilter/AdminRoleInputFilter.php b/src/Admin/src/InputFilter/AdminRoleInputFilter.php
index fe08171..dfa10e4 100644
--- a/src/Admin/src/InputFilter/AdminRoleInputFilter.php
+++ b/src/Admin/src/InputFilter/AdminRoleInputFilter.php
@@ -7,6 +7,9 @@
use Api\Admin\InputFilter\Input\UuidInput;
use Laminas\InputFilter\InputFilter;
+/**
+ * @extends InputFilter