mirror of
https://github.com/DesignPatternsPHP/DesignPatternsPHP.git
synced 2025-08-01 12:40:11 +02:00
cs fix
This commit is contained in:
@@ -8,18 +8,18 @@ abstract class AbstractSpecification implements SpecificationInterface
|
||||
{
|
||||
/**
|
||||
* Checks if given item meets all criteria
|
||||
*
|
||||
*
|
||||
* @param Item $item
|
||||
*
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
abstract public function isSatisfiedBy(Item $item);
|
||||
|
||||
/**
|
||||
* Creates a new logical AND specification
|
||||
*
|
||||
*
|
||||
* @param SpecificationInterface $spec
|
||||
*
|
||||
*
|
||||
* @return SpecificationInterface
|
||||
*/
|
||||
public function plus(SpecificationInterface $spec)
|
||||
@@ -29,9 +29,9 @@ abstract class AbstractSpecification implements SpecificationInterface
|
||||
|
||||
/**
|
||||
* Creates a new logical OR composite specification
|
||||
*
|
||||
*
|
||||
* @param SpecificationInterface $spec
|
||||
*
|
||||
*
|
||||
* @return SpecificationInterface
|
||||
*/
|
||||
public function either(SpecificationInterface $spec)
|
||||
@@ -41,11 +41,11 @@ abstract class AbstractSpecification implements SpecificationInterface
|
||||
|
||||
/**
|
||||
* Creates a new logical NOT specification
|
||||
*
|
||||
*
|
||||
* @return SpecificationInterface
|
||||
*/
|
||||
public function not()
|
||||
{
|
||||
return new Not($this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -31,4 +31,4 @@ class Not extends AbstractSpecification
|
||||
{
|
||||
return !$this->spec->isSatisfiedBy($item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -12,10 +12,9 @@ class Plus extends AbstractSpecification
|
||||
|
||||
/**
|
||||
* Creation of a locical AND of two specifications
|
||||
*
|
||||
*
|
||||
* @param SpecificationInterface $left
|
||||
* @param SpecificationInterface $right
|
||||
|
||||
*/
|
||||
public function __construct(SpecificationInterface $left, SpecificationInterface $right)
|
||||
{
|
||||
@@ -25,13 +24,13 @@ class Plus extends AbstractSpecification
|
||||
|
||||
/**
|
||||
* Checks if the composite AND of specifications passes
|
||||
*
|
||||
*
|
||||
* @param Item $item
|
||||
*
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isSatisfiedBy(Item $item)
|
||||
{
|
||||
return $this->left->isSatisfiedBy($item) && $this->right->isSatisfiedBy($item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -31,17 +31,17 @@ class PriceSpecification extends AbstractSpecification
|
||||
|
||||
/**
|
||||
* Checks if Item price falls between bounds
|
||||
*
|
||||
*
|
||||
* @param Item $item
|
||||
*
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isSatisfiedBy(Item $item)
|
||||
{
|
||||
if ( !empty($this->maxPrice) && $item->getPrice() > $this->maxPrice) {
|
||||
if (!empty($this->maxPrice) && $item->getPrice() > $this->maxPrice) {
|
||||
return false;
|
||||
}
|
||||
if ( !empty($this->minPrice) && $item->getPrice() < $this->minPrice) {
|
||||
if (!empty($this->minPrice) && $item->getPrice() < $this->minPrice) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@@ -8,26 +8,24 @@ interface SpecificationInterface
|
||||
{
|
||||
/**
|
||||
* A boolean evaluation indicating if the object meets the specification
|
||||
*
|
||||
*
|
||||
* @param Item $item
|
||||
*
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isSatisfiedBy(Item $item);
|
||||
|
||||
/**
|
||||
* Creates a logical AND specification
|
||||
*
|
||||
*
|
||||
* @param SpecificationInterface $spec
|
||||
|
||||
*/
|
||||
public function plus(SpecificationInterface $spec);
|
||||
|
||||
/**
|
||||
* Creates a logical OR specification
|
||||
*
|
||||
*
|
||||
* @param SpecificationInterface $spec
|
||||
|
||||
*/
|
||||
public function either(SpecificationInterface $spec);
|
||||
|
||||
@@ -35,4 +33,4 @@ interface SpecificationInterface
|
||||
* Creates a logical not specification
|
||||
*/
|
||||
public function not();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user