Skip to content

Unique and non unique tokens #7

@fiedsch

Description

@fiedsch

The Fiedsch\Data\Augmentation\Rules\TokenRule generates unique tokens by using getUniqueToken() without stating this in its name.

This method is slowed down by the uniqueness checks when large amounts of tokens are generated.

While we could use

$augmentor->addRule('token', new class implements AugmentationRule {
            public function __invoke(Augmentor $augmentor, array $data): array
            {
                return ['token' => $augmentor['token']->createToken()];
            }
        });

to generate tokens without uniqueness checks an idea might be to introduce a constructor in TokenRule that allows to specify if tokens are to be generated unique or not (with unique being the default for BC reasons). With that change we could use

 $augmentor->addRule('token', new TokenRule(false));

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions