true, * 'no', 'off' => false, * default => $value, * }; * * return $next($value); * } * } * * final class User * { * public string $name; * * #[\My\App\CastToBool] * public bool $isActive; * } * * $user = (new \OCA\Talk\Vendor\CuyZ\Valinor\MapperBuilder()) * ->mapper() * ->map(User::class, [ * 'name' => 'John Doe', * 'isActive' => 'yes', * ]); * * $user->name === 'John Doe'; * $user->isActive === true; * ``` * * Attribute converters can also be used on function parameters when mapping * arguments: * * ``` * function someFunction(string $name, #[\My\App\CastToBool] bool $isActive) { * // … * }; * * $arguments = (new \OCA\Talk\Vendor\CuyZ\Valinor\MapperBuilder()) * ->argumentsMapper() * ->mapArguments(someFunction(...), [ * 'name' => 'John Doe', * 'isActive' => 'yes', * ]); * * $arguments['name'] === 'John Doe'; * $arguments['isActive'] === true; * ``` * @api */ #[Attribute(Attribute::TARGET_CLASS)] final class AsConverter {}