Skip to content

Commit

Permalink
[Filter] Adding Custom Exceptions
Browse files Browse the repository at this point in the history
[Fitler] Adding initial tests for Filter Rules
[Tests] Adding bootstrap and ClassLoader
[DMS] Fixing vendors
  • Loading branch information
rdohms committed Jul 18, 2011
1 parent 76df592 commit 5000eca
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 30 deletions.
8 changes: 8 additions & 0 deletions Exception/FilterException.php
@@ -0,0 +1,8 @@
<?php

namespace DMS\Filter\Exception;

class FilterException extends \RuntimeException
{

}
9 changes: 9 additions & 0 deletions Exception/InvalidOptionsException.php
@@ -0,0 +1,9 @@
<?php

namespace DMS\Filter\Exception;

class InvalidOptionsException extends RuleOptionsException
{

}

8 changes: 8 additions & 0 deletions Exception/MissingOptionsException.php
@@ -0,0 +1,8 @@
<?php

namespace DMS\Filter\Exception;

class MissingOptionsException extends RuleOptionsException
{

}
9 changes: 9 additions & 0 deletions Exception/RuleDefinitionException.php
@@ -0,0 +1,9 @@
<?php

namespace DMS\Filter\Exception;

class RuleDefinitionException extends FilterException
{

}

21 changes: 21 additions & 0 deletions Exception/RuleOptionsException.php
@@ -0,0 +1,21 @@
<?php

namespace DMS\Filter\Exception;

class RuleOptionsException extends FilterException
{
private $options;

public function __construct($message, array $options)
{
parent::__construct($message);

$this->options = $options;
}

public function getOptions()
{
return $this->options;
}
}

29 changes: 0 additions & 29 deletions Mapping/Cache/CacheInterface.php

This file was deleted.

7 changes: 6 additions & 1 deletion Rules/Rule.php
Expand Up @@ -2,6 +2,10 @@


namespace DMS\Filter\Rules; namespace DMS\Filter\Rules;


use DMS\Filter\Exception\InvalidOptionsException,
DMS\Filter\Exception\MissingOptionsException,
DMS\Filter\Exception\RuleDefinitionException;

/** /**
* Base class for a Filtering Rule, it implements common behaviour * Base class for a Filtering Rule, it implements common behaviour
* *
Expand Down Expand Up @@ -40,6 +44,7 @@ abstract function applyFilter($value);
* NULL * NULL
* *
* @link https://github.com/symfony/symfony/blob/master/src/Symfony/Component/Validator/Constraint.php * @link https://github.com/symfony/symfony/blob/master/src/Symfony/Component/Validator/Constraint.php
* @todo rewrite this
*/ */
public function __construct($options = null) public function __construct($options = null)
{ {
Expand All @@ -63,7 +68,7 @@ public function __construct($options = null)
$option = $this->getDefaultOption(); $option = $this->getDefaultOption();


if (null === $option) { if (null === $option) {
throw new ConstraintDefinitionException( throw new RuleDefinitionException(
sprintf('No default option is configured for constraint %s', get_class($this)) sprintf('No default option is configured for constraint %s', get_class($this))
); );
} }
Expand Down

0 comments on commit 5000eca

Please sign in to comment.