for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* File was created 30.09.2015 07:57
*/
namespace PeekAndPoke\Component\Slumber\Annotation\Slumber;
use Doctrine\Common\Annotations\Annotation;
use PeekAndPoke\Component\Slumber\Core\Exception\SlumberException;
use PeekAndPoke\Component\Slumber\Core\Validation\ValidationContext;
use PeekAndPoke\Types\Enumerated;
* @Annotation
* @Annotation\Target("PROPERTY")
*
* @author Karsten J. Gerber <[email protected]>
class AsEnum extends PropertyMappingMarkerBase
{
* @param ValidationContext $context
* @throws SlumberException
public function validate(ValidationContext $context)
if (empty($this->value)) {
throw $this->createValidationException(
$context,
'you must provide a class as value. Example @Slumber\AsObject( MyEnum::class )'
);
}
if (!class_exists($this->value)) {
"you provided the non-existing class '$this->value'"
if (!is_a($this->value, Enumerated::class, true)) {
"you provided the class '$this->value' which does not extend " . Enumerated::class
* @return bool
public function keepNullValuesInCollections()
return false;