for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* Copyright 2014 Jonathan Bouzekri. All rights reserved.
*
* @copyright Copyright 2014 Jonathan Bouzekri <[email protected]>
* @license https://github.com/jbouzekri/FileUploaderBundle/blob/master/LICENSE
* @link https://github.com/jbouzekri/FileUploaderBundle
*/
namespace Jb\Bundle\FileUploaderBundle\Service\Validator;
use Symfony\Component\OptionsResolver\OptionsResolver;
* AbstractValidator
* @author jobou
abstract class AbstractValidator
{
* Configure the validator
* @param OptionsResolver $resolver
protected function configureOptions(OptionsResolver $resolver)
}
* Apply the validator
* @param mixed $value
* @param array $configuration
* @throws \Jb\Bundle\FileUploaderBundle\Exception\ValidationException
public function applyValidator($value, array $configuration)
// Validate configuration
$resolver = new OptionsResolver();
$this->configureOptions($resolver);
$configuration = $resolver->resolve($configuration);
$this->validate($value, $configuration);
* Extract the value used in the validator
* @return mixed|string
protected function formatValue($value)
if ($value instanceof \SplFileInfo) {
return $value->getPathname();
return $value;
* Validate a value
abstract protected function validate($value, array $configuration);