bluzphp /
skeleton
| 1 | <?php |
||
| 2 | /** |
||
| 3 | * @copyright Bluz PHP Team |
||
| 4 | * @link https://github.com/bluzphp/skeleton |
||
| 5 | */ |
||
| 6 | |||
| 7 | declare(strict_types=1); |
||
| 8 | |||
| 9 | namespace Application\UsersActions; |
||
| 10 | |||
| 11 | use Bluz\Proxy\Db; |
||
|
0 ignored issues
–
show
|
|||
| 12 | |||
| 13 | /** |
||
| 14 | * Table of User Actions |
||
| 15 | * |
||
| 16 | * @package Application\Users |
||
| 17 | * |
||
| 18 | * @method static ?Row findRow($primaryKey) |
||
| 19 | * @see \Bluz\Db\Table::findRow() |
||
| 20 | * @method static ?Row findRowWhere($whereList) |
||
| 21 | * @see \Bluz\Db\Table::findRowWhere() |
||
| 22 | */ |
||
| 23 | class Table extends \Bluz\Db\Table |
||
|
0 ignored issues
–
show
The type
Bluz\Db\Table was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||
| 24 | { |
||
| 25 | public const ACTION_ACTIVATION = 'activation'; |
||
| 26 | public const ACTION_CHANGE_EMAIL = 'email'; |
||
| 27 | public const ACTION_RECOVERY = 'recovery'; |
||
| 28 | public const ACTION_REMOVE = 'remove'; |
||
| 29 | |||
| 30 | /** |
||
| 31 | * Table |
||
| 32 | * |
||
| 33 | * @var string |
||
| 34 | */ |
||
| 35 | protected $name = 'users_actions'; |
||
| 36 | |||
| 37 | /** |
||
| 38 | * Primary key(s) |
||
| 39 | * |
||
| 40 | * @var array |
||
| 41 | */ |
||
| 42 | protected $primary = ['userId', 'code']; |
||
| 43 | |||
| 44 | /** |
||
| 45 | * generate action with token |
||
| 46 | * |
||
| 47 | * @param int $userId |
||
| 48 | * @param string $action |
||
| 49 | * @param int $expired in days |
||
| 50 | * @param array $params |
||
| 51 | * |
||
| 52 | * @return Row |
||
| 53 | * @throws \Bluz\Db\Exception\DbException |
||
| 54 | * @throws \Bluz\Db\Exception\InvalidPrimaryKeyException |
||
| 55 | * @throws \Bluz\Db\Exception\TableNotFoundException |
||
| 56 | */ |
||
| 57 | public function generate($userId, $action, $expired = 5, $params = []): Row |
||
| 58 | { |
||
| 59 | // remove previously generated tokens |
||
| 60 | Db::delete($this->name) |
||
| 61 | ->where('userId = ?', $userId) |
||
| 62 | ->andWhere('action = ?', $action) |
||
| 63 | ->execute(); |
||
| 64 | |||
| 65 | // create new row |
||
| 66 | $actionRow = new Row(); |
||
| 67 | $actionRow->userId = $userId; |
||
| 68 | $actionRow->action = $action; |
||
| 69 | $actionRow->code = bin2hex(random_bytes(32)); |
||
| 70 | $actionRow->expired = gmdate('Y-m-d H:i:s', strtotime("+$expired day")); |
||
| 71 | $actionRow->params = $params; |
||
| 72 | $actionRow->save(); |
||
| 73 | |||
| 74 | return $actionRow; |
||
| 75 | } |
||
| 76 | } |
||
| 77 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths