mirror of
https://github.com/flextype/flextype.git
synced 2025-08-11 07:34:22 +02:00
feat(tokens): add Tokens class #566
This commit is contained in:
34
src/flextype/Tokens/Tokens.php
Normal file
34
src/flextype/Tokens/Tokens.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* Flextype (https://flextype.org)
|
||||
* Founded by Sergey Romanenko and maintained by Flextype Community.
|
||||
*/
|
||||
|
||||
namespace Flextype\Tokens;
|
||||
|
||||
use Atomastic\Macroable\Macroable;
|
||||
use Flextype\Entries;
|
||||
use Exception;
|
||||
|
||||
class Tokens extends Entries
|
||||
{
|
||||
use Macroable;
|
||||
|
||||
public function create(string $id, array $data = []): bool
|
||||
{
|
||||
throw new Exception('Use generate method instead');
|
||||
return false;
|
||||
}
|
||||
|
||||
public function generate(array $data = []): string
|
||||
{
|
||||
$id = strings()->random()->toString();
|
||||
|
||||
parent::create($id, $data);
|
||||
|
||||
return $id;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user