Permalink
Browse files

[Filter] Updated README

[Filter] Added StripNewlines Rule and tests
[Filter] Added further tests to ClassMetadataFactory
[Filter] Complemented tests for 100% coverage
  • Loading branch information...
1 parent fc7b8f5 commit 1892ca39e354231f9880bb2be7b3922ec23fd77e @rdohms committed Jul 19, 2011
Showing with 57 additions and 5 deletions.
  1. +2 −2 Mapping/ClassMetadataFactory.php
  2. +32 −3 README.md
  3. +23 −0 Rules/StripNewlines.php
View
4 Mapping/ClassMetadataFactory.php
@@ -10,7 +10,7 @@
* @package DMS
* @subpackage Filter
*/
-class ClassMetadataFactory
+class ClassMetadataFactory implements ClassMetadataFactoryInterface
{
/**
* @var Loader\LoaderInterface
@@ -86,7 +86,7 @@ private function parseClassMetadata($class)
$this->setParsedClass($class, $metadata);
if ($this->cache !== null) {
- $this->cache->write($class, $metadata);
+ $this->cache->save($class, $metadata);
}
return $metadata;
View
35 README.md
@@ -4,17 +4,46 @@ This library provides a service that can be used to filter object values based o
## Usage
-TODO
+```php
+<?php
+ //Get Doctrine Reader
+ $reader = new Annotations\AnnotationReader();
+ $reader->setEnableParsePhpImports(true);
+
+ //Load AnnotationLoader
+ $loader = new Mapping\Loader\AnnotationLoader($reader);
+ $this->loader = $loader;
+
+ //Get a MetadataFactory
+ $metadataFactory = new Mapping\ClassMetadataFactory($loader);
+
+ //Get a Filter
+ $filter = new Filter($metadataFactory);
+
+ //Filter object
+ $filter->filter($object);
+?>
+```
## Dependencies
This package relies on these external libraries:
* Doctrine Common: Reader and Cache
+## Contributing
+
+Feel free to send pull requests, just follow these guides:
+
+* Fork
+* Code
+* Test
+ * Tests are in: https://github.com/rdohms/DMS
+ * Just create Testcase and run `phpunit` inside the `tests` folder
+* Submit PR
+
## Credits
-This library is inspired by the Symfony 2 Validator component and is meant to work alongside it. Some
-of the code was inspired on it, so credit is due to the excellent work done over there.
+This library is inspired by the Symfony 2 Validator component and is meant to work alongside it.
Symfony 2 Validator: https://github.com/symfony/symfony/blob/master/src/Symfony/Component/Validator
View
23 Rules/StripNewlines.php
@@ -0,0 +1,23 @@
+<?php
+
+namespace DMS\Filter\Rules;
+
+/**
+ * StripNewlines Rule
+ *
+ * @package DMS
+ * @subpackage Filter
+ *
+ * @Annotation
+ */
+class StripNewlines extends Rule
+{
+ /**
+ * {@inheritDoc}
+ */
+ public function applyFilter($value)
+ {
+ return str_replace(array("\n", "\r"), '', $value);
+ }
+
+}

0 comments on commit 1892ca3

Please sign in to comment.