Code Duplication    Length = 42-43 lines in 2 locations

Service/ResolverChain.php 1 location

@@ 21-62 (lines=42) @@
18
 *
19
 * @author jobou
20
 */
21
class ResolverChain
22
{
23
    /**
24
     * @var array
25
     */
26
    private $resolvers;
27
28
    /**
29
     * Constructor
30
     */
31
    public function __construct()
32
    {
33
        $this->resolvers = array();
34
    }
35
36
    /**
37
     * Add a resolver
38
     *
39
     * @param \Jb\Bundle\FileUploaderBundle\Service\Resolver\ResolverInterface $resolver
40
     */
41
    public function addResolver(ResolverInterface $resolver, $alias)
42
    {
43
        $this->resolvers[$alias] = $resolver;
44
    }
45
46
    /**
47
     *
48
     * @param string $alias
49
     *
50
     * @return \Jb\Bundle\FileUploaderBundle\Service\Resolver\ResolverInterface
51
     *
52
     * @throws \Jb\Bundle\FileUploaderBundle\Exception\JbFileUploaderException
53
     */
54
    public function getResolver($alias)
55
    {
56
        if (array_key_exists($alias, $this->resolvers)) {
57
            return $this->resolvers[$alias];
58
        }
59
60
        throw new JbFileUploaderException('Unknown resolver ' . $alias);
61
    }
62
}
63

Service/ValidatorChain.php 1 location

@@ 21-63 (lines=43) @@
18
 *
19
 * @author jobou
20
 */
21
class ValidatorChain
22
{
23
    /**
24
     * @var array
25
     */
26
    private $validators;
27
28
    /**
29
     * Constructor
30
     */
31
    public function __construct()
32
    {
33
        $this->validators = array();
34
    }
35
36
    /**
37
     * Add a validator
38
     *
39
     * @param \Jb\Bundle\FileUploaderBundle\Service\Validator\AbstractValidator $validator
40
     */
41
    public function addValidator(AbstractValidator $validator, $alias)
42
    {
43
        $this->validators[$alias] = $validator;
44
    }
45
46
    /**
47
     * Get a validator by its alias
48
     *
49
     * @param string $alias
50
     *
51
     * @return \Jb\Bundle\FileUploaderBundle\Service\Validator\AbstractValidator
52
     *
53
     * @throws \Jb\Bundle\FileUploaderBundle\Exception\JbFileUploaderException
54
     */
55
    public function getValidator($alias)
56
    {
57
        if (array_key_exists($alias, $this->validators)) {
58
            return $this->validators[$alias];
59
        }
60
61
        throw new JbFileUploaderException('Unknown validator ' . $alias);
62
    }
63
}
64