abterphp /
admin
| 1 | <?php |
||
| 2 | |||
| 3 | declare(strict_types=1); |
||
| 4 | |||
| 5 | namespace AbterPhp\Admin\Http\Controllers\Admin\Execute; |
||
| 6 | |||
| 7 | use AbterPhp\Admin\Http\Controllers\Admin\ExecuteAbstract; |
||
| 8 | use AbterPhp\Admin\Service\Execute\ApiClient as RepoService; |
||
| 9 | use AbterPhp\Framework\Constant\Session; |
||
| 10 | use AbterPhp\Framework\I18n\ITranslator; |
||
| 11 | use AbterPhp\Framework\Session\FlashService; |
||
| 12 | use Opulence\Routing\Urls\UrlGenerator; |
||
| 13 | use Opulence\Sessions\ISession; |
||
| 14 | use Psr\Log\LoggerInterface; |
||
| 15 | |||
| 16 | class ApiClient extends ExecuteAbstract |
||
| 17 | { |
||
| 18 | public const ENTITY_SINGULAR = 'apiClient'; |
||
| 19 | public const ENTITY_PLURAL = 'apiClients'; |
||
| 20 | |||
| 21 | public const ENTITY_TITLE_SINGULAR = 'admin:apiClient'; |
||
| 22 | public const ENTITY_TITLE_PLURAL = 'admin:apiClients'; |
||
| 23 | |||
| 24 | /** |
||
| 25 | * ApiClient constructor. |
||
| 26 | * |
||
| 27 | * @param FlashService $flashService |
||
| 28 | * @param LoggerInterface $logger |
||
| 29 | * @param ITranslator $translator |
||
| 30 | * @param UrlGenerator $urlGenerator |
||
| 31 | * @param RepoService $repoService |
||
| 32 | * @param ISession $session |
||
| 33 | */ |
||
| 34 | public function __construct( |
||
| 35 | FlashService $flashService, |
||
| 36 | LoggerInterface $logger, |
||
| 37 | ITranslator $translator, |
||
| 38 | UrlGenerator $urlGenerator, |
||
| 39 | RepoService $repoService, |
||
| 40 | ISession $session |
||
| 41 | ) { |
||
| 42 | parent::__construct( |
||
| 43 | $flashService, |
||
| 44 | $logger, |
||
| 45 | $translator, |
||
| 46 | $urlGenerator, |
||
| 47 | $repoService, |
||
| 48 | $session |
||
| 49 | ); |
||
| 50 | } |
||
| 51 | |||
| 52 | /** |
||
| 53 | * @return array |
||
| 54 | */ |
||
| 55 | protected function getPostData(): array |
||
| 56 | { |
||
| 57 | $postData = $this->request->getPost()->getAll(); |
||
| 58 | |||
| 59 | if ($postData) { |
||
|
0 ignored issues
–
show
|
|||
| 60 | $postData['user_id'] = $this->session->get(Session::USER_ID); |
||
| 61 | } |
||
| 62 | |||
| 63 | return $postData; |
||
| 64 | } |
||
| 65 | } |
||
| 66 |
This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.
Consider making the comparison explicit by using
empty(..)or! empty(...)instead.