Skip to content

SpecificationFactory #18

@juliangut

Description

@juliangut

Needing to write

use Rb\Specification\Doctrine\Condition\Equals;
use Rb\Specification\Doctrine\Condition\IsNull;
use Rb\Specification\Doctrine\Condition\LessThan;
use Rb\Specification\Doctrine\Logic\AndX;
use Rb\Specification\Doctrine\Logic\OrX;
...

is tedious AND bloated (even with PHP7 syntax) a factory instead would be an improvement and let you choose whichever method you like

use Rb\Specification\Doctrine\SpecificationFactory as Factory;
use Rb\Specification\Doctrine\Specification;

$spec = new Specification([
    Factory::Equals('ended', 0),
    Factory::OrX(
        Factory::LessThan('endDate', new \DateTime()),
        Factory::AndX(
            Factory::IsNull('endDate'),
            Factory::LessThan('startDate', new \DateTime('-4weeks'))
        )
    )
]);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions