Permalink
Browse files

[Filter] Adding Custom Exceptions

[Fitler] Adding initial tests for Filter Rules
[Tests] Adding bootstrap and ClassLoader
[DMS] Fixing vendors
  • Loading branch information...
1 parent 76df592 commit 5000eca4a9109bb5625dfb54a3e31c54d8c0c39d @rdohms committed Jul 18, 2011
@@ -0,0 +1,8 @@
+<?php
+
+namespace DMS\Filter\Exception;
+
+class FilterException extends \RuntimeException
+{
+
+}
@@ -0,0 +1,9 @@
+<?php
+
+namespace DMS\Filter\Exception;
+
+class InvalidOptionsException extends RuleOptionsException
+{
+
+}
+
@@ -0,0 +1,8 @@
+<?php
+
+namespace DMS\Filter\Exception;
+
+class MissingOptionsException extends RuleOptionsException
+{
+
+}
@@ -0,0 +1,9 @@
+<?php
+
+namespace DMS\Filter\Exception;
+
+class RuleDefinitionException extends FilterException
+{
+
+}
+
@@ -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;
+ }
+}
+
@@ -1,29 +0,0 @@
-<?php
-
-namespace DMS\Filter\Mapping\Cache;
-
-interface CacheInterface
-{
- /**
- * Returns whether metadata for the given class exists in the cache
- *
- * @param string $class
- */
- function has($class);
-
- /**
- * Returns the metadata for the given class from the cache
- *
- * @param string $class Class Name
- *
- * @return ClassMetadata
- */
- function read($class);
-
- /**
- * Stores a class metadata in the cache
- *
- * @param ClassMetadata $metadata A Class Metadata
- */
- function write(ClassMetadata $metadata);
-}
View
@@ -2,6 +2,10 @@
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
*
@@ -40,6 +44,7 @@
* NULL
*
* @link https://github.com/symfony/symfony/blob/master/src/Symfony/Component/Validator/Constraint.php
+ * @todo rewrite this
*/
public function __construct($options = null)
{
@@ -63,7 +68,7 @@ public function __construct($options = null)
$option = $this->getDefaultOption();
if (null === $option) {
- throw new ConstraintDefinitionException(
+ throw new RuleDefinitionException(
sprintf('No default option is configured for constraint %s', get_class($this))
);
}

0 comments on commit 5000eca

Please sign in to comment.