Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

[Filter] Updated README

[Filter] Added StripNewlines Rule and tests
[Filter] Added further tests to ClassMetadataFactory
[Filter] Complemented tests for 100% coverage
  • Loading branch information...
commit 1892ca39e354231f9880bb2be7b3922ec23fd77e 1 parent fc7b8f5
Rafael Dohms authored
4 Mapping/ClassMetadataFactory.php
@@ -10,7 +10,7 @@
10 10 * @package DMS
11 11 * @subpackage Filter
12 12 */
13   -class ClassMetadataFactory
  13 +class ClassMetadataFactory implements ClassMetadataFactoryInterface
14 14 {
15 15 /**
16 16 * @var Loader\LoaderInterface
@@ -86,7 +86,7 @@ private function parseClassMetadata($class)
86 86 $this->setParsedClass($class, $metadata);
87 87
88 88 if ($this->cache !== null) {
89   - $this->cache->write($class, $metadata);
  89 + $this->cache->save($class, $metadata);
90 90 }
91 91
92 92 return $metadata;
35 README.md
Source Rendered
@@ -4,7 +4,26 @@ This library provides a service that can be used to filter object values based o
4 4
5 5 ## Usage
6 6
7   -TODO
  7 +```php
  8 +<?php
  9 + //Get Doctrine Reader
  10 + $reader = new Annotations\AnnotationReader();
  11 + $reader->setEnableParsePhpImports(true);
  12 +
  13 + //Load AnnotationLoader
  14 + $loader = new Mapping\Loader\AnnotationLoader($reader);
  15 + $this->loader = $loader;
  16 +
  17 + //Get a MetadataFactory
  18 + $metadataFactory = new Mapping\ClassMetadataFactory($loader);
  19 +
  20 + //Get a Filter
  21 + $filter = new Filter($metadataFactory);
  22 +
  23 + //Filter object
  24 + $filter->filter($object);
  25 +?>
  26 +```
8 27
9 28 ## Dependencies
10 29
@@ -12,9 +31,19 @@ This package relies on these external libraries:
12 31
13 32 * Doctrine Common: Reader and Cache
14 33
  34 +## Contributing
  35 +
  36 +Feel free to send pull requests, just follow these guides:
  37 +
  38 +* Fork
  39 +* Code
  40 +* Test
  41 + * Tests are in: https://github.com/rdohms/DMS
  42 + * Just create Testcase and run `phpunit` inside the `tests` folder
  43 +* Submit PR
  44 +
15 45 ## Credits
16 46
17   -This library is inspired by the Symfony 2 Validator component and is meant to work alongside it. Some
18   -of the code was inspired on it, so credit is due to the excellent work done over there.
  47 +This library is inspired by the Symfony 2 Validator component and is meant to work alongside it.
19 48
20 49 Symfony 2 Validator: https://github.com/symfony/symfony/blob/master/src/Symfony/Component/Validator
23 Rules/StripNewlines.php
... ... @@ -0,0 +1,23 @@
  1 +<?php
  2 +
  3 +namespace DMS\Filter\Rules;
  4 +
  5 +/**
  6 + * StripNewlines Rule
  7 + *
  8 + * @package DMS
  9 + * @subpackage Filter
  10 + *
  11 + * @Annotation
  12 + */
  13 +class StripNewlines extends Rule
  14 +{
  15 + /**
  16 + * {@inheritDoc}
  17 + */
  18 + public function applyFilter($value)
  19 + {
  20 + return str_replace(array("\n", "\r"), '', $value);
  21 + }
  22 +
  23 +}

0 comments on commit 1892ca3

Please sign in to comment.
Something went wrong with that request. Please try again.