mirror of
https://github.com/DesignPatternsPHP/DesignPatternsPHP.git
synced 2025-07-31 12:10:10 +02:00
cs fix
This commit is contained in:
@@ -45,7 +45,8 @@ class ChainTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertObjectHasAttribute('response', $request);
|
||||
$this->assertEquals('baz', $request->response);
|
||||
// despite both handle owns the 'bar' key, the FastStorage is responding first
|
||||
$this->assertEquals('DesignPatterns\Behavioral\ChainOfResponsibilities\Responsible\FastStorage', $request->forDebugOnly);
|
||||
$className = 'DesignPatterns\Behavioral\ChainOfResponsibilities\Responsible\FastStorage';
|
||||
$this->assertEquals($className, $request->forDebugOnly);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -60,7 +61,8 @@ class ChainTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertObjectHasAttribute('response', $request);
|
||||
$this->assertEquals('bar', $request->response);
|
||||
// FastStorage has no 'foo' key, the SlowStorage is responding
|
||||
$this->assertEquals('DesignPatterns\Behavioral\ChainOfResponsibilities\Responsible\SlowStorage', $request->forDebugOnly);
|
||||
$className = 'DesignPatterns\Behavioral\ChainOfResponsibilities\Responsible\SlowStorage';
|
||||
$this->assertEquals($className, $request->forDebugOnly);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -73,6 +75,7 @@ class ChainTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
$this->assertFalse($ret);
|
||||
// the last responsible :
|
||||
$this->assertEquals('DesignPatterns\Behavioral\ChainOfResponsibilities\Responsible\SlowStorage', $request->forDebugOnly);
|
||||
$className = 'DesignPatterns\Behavioral\ChainOfResponsibilities\Responsible\SlowStorage';
|
||||
$this->assertEquals($className, $request->forDebugOnly);
|
||||
}
|
||||
}
|
||||
|
@@ -13,7 +13,7 @@ class BookList implements \Countable
|
||||
return $this->books[$bookNumberToGet];
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return null;
|
||||
}
|
||||
|
||||
public function addBook(Book $book)
|
||||
|
@@ -74,4 +74,4 @@ class BookListIterator implements \Iterator
|
||||
{
|
||||
$this->currentBook = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -20,4 +20,4 @@ class BookListReverseIterator extends BookListIterator
|
||||
{
|
||||
return 0 <= $this->currentBook;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -63,4 +63,4 @@ class IteratorTest extends \PHPUnit_Framework_TestCase
|
||||
$iterator->next();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -53,10 +53,9 @@ class ObserverTest extends \PHPUnit_Framework_TestCase
|
||||
$subject->attach($observer);
|
||||
|
||||
$observer->expects($this->once())
|
||||
->method('update')
|
||||
->with($subject);
|
||||
->method('update')
|
||||
->with($subject);
|
||||
|
||||
$subject->notify();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@@ -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();
|
||||
}
|
||||
}
|
||||
|
@@ -30,10 +30,10 @@ class ObjectCollection
|
||||
*/
|
||||
public function sort()
|
||||
{
|
||||
if (!$this->comparator){
|
||||
throw new \LogicException("Comparator is not set");
|
||||
if (!$this->comparator) {
|
||||
throw new \LogicException("Comparator is not set");
|
||||
}
|
||||
|
||||
|
||||
$callback = array($this->comparator, 'compare');
|
||||
uasort($this->elements, $callback);
|
||||
|
||||
|
@@ -31,8 +31,8 @@ class JourneyTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
$journey = $this->getMockForAbstractClass('DesignPatterns\Behavioral\TemplateMethod\Journey');
|
||||
$journey->expects($this->once())
|
||||
->method('enjoyVacation')
|
||||
->will($this->returnCallback(array($this, 'mockUpVacation')));
|
||||
->method('enjoyVacation')
|
||||
->will($this->returnCallback(array($this, 'mockUpVacation')));
|
||||
$this->expectOutputRegex('#Las Vegas#');
|
||||
$journey->takeATrip();
|
||||
}
|
||||
@@ -41,5 +41,4 @@ class JourneyTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
echo "Fear and loathing in Las Vegas\n";
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@@ -43,5 +43,4 @@ class VisitorTest extends \PHPUnit_Framework_TestCase
|
||||
$mock = $this->getMockForAbstractClass('DesignPatterns\Behavioral\Visitor\Role');
|
||||
$mock->accept($this->visitor);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user