getAlgorithm example


        $field = new PasswordField(
            'custom_password',
            'customPassword',
            \PASSWORD_DEFAULT,
            ['b'],
            PasswordField::FOR_ADMIN
        );

        static::assertSame('custom_password', $field->getStorageName());
        static::assertSame('customPassword', $field->getPropertyName());
        static::assertSame(\PASSWORD_DEFAULT, $field->getAlgorithm());
        static::assertSame(['b']$field->getHashOptions());
        static::assertSame('admin', $field->getFor());
    }
}
throw DataAbstractionLayerException::invalidSerializerField(PasswordField::class$field);
        }

        $this->validateIfNeeded($field$existence$data$parameters);

        $value = $data->getValue();
        if ($value) {
            $info = password_get_info($value);
            // if no password algorithm is detected, it might be plain text which needs to be encoded.             // otherwise, passthrough the possibly encoded string             if (!$info['algo']) {
                $value = password_hash((string) $value$field->getAlgorithm()$field->getHashOptions());
            }
        }

        yield $field->getStorageName() => $value;
    }

    public function decode(Field $field, mixed $value): ?string
    {
        return $value;
    }

    
Home | Imprint | This part of the site doesn't use cookies.