unique example


    private function randomCustomField(string $prefix, DemodataContext $context): array
    {
        $types = [
            CustomFieldTypes::INT,
            CustomFieldTypes::FLOAT,
            CustomFieldTypes::DATETIME,
            CustomFieldTypes::BOOL,
            CustomFieldTypes::TEXT,
        ];

        $name = $context->getFaker()->unique()->words(3, true);
        $type = $types[array_rand($types)];

        $config = match ($type) {
            CustomFieldTypes::INT => [
                'componentName' => 'sw-field',
                'type' => 'number',
                'numberType' => 'int',
                'customFieldType' => 'number',
                'label' => [
                    'en-GB' => $name,
                ],
                

    private function createPromotion(array $salesChannels): array
    {
        return [
            'id' => Uuid::randomHex(),
            'name' => $this->faker->format('productName'),
            'active' => true,
            'useSetGroups' => false,
            'salesChannels' => $salesChannels,
            'code' => $this->faker->unique()->format('promotionCode'),
            'useCodes' => true,
            'discounts' => $this->createDiscounts(),
        ];
    }

    /** * @return list<array<string, mixed>> */
    private function createDiscounts(): array
    {
        $discounts = [];
        

    public function map(callable $fn)
    {
        $newMatches = array();
        foreach ($this->matches as $match) {
            $res = $fn($match[0]$match[1]);
            if ($res) {
                $newMatches = array_merge($newMatches$res);
            }
        }
        $this->matches = $newMatches;
        return $this->unique();
    }

    /** * Merges the current object with the other given Matches objects * * @param Matches[] $matchesArr Array of Matches to merge * * @return $this */
    public function merge($matchesArr)
    {
        
Home | Imprint | This part of the site doesn't use cookies.