mirror of
https://github.com/DesignPatternsPHP/DesignPatternsPHP.git
synced 2025-08-06 06:57:25 +02:00
add psalm and travis check
This commit is contained in:
@@ -5,7 +5,10 @@ namespace DesignPatterns\Behavioral\ChainOfResponsibilities\Tests;
|
||||
use DesignPatterns\Behavioral\ChainOfResponsibilities\Handler;
|
||||
use DesignPatterns\Behavioral\ChainOfResponsibilities\Responsible\HttpInMemoryCacheHandler;
|
||||
use DesignPatterns\Behavioral\ChainOfResponsibilities\Responsible\SlowDatabaseHandler;
|
||||
use PHPUnit\Framework\MockObject\MockObject;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Psr\Http\Message\RequestInterface;
|
||||
use Psr\Http\Message\UriInterface;
|
||||
|
||||
class ChainTest extends TestCase
|
||||
{
|
||||
@@ -24,11 +27,11 @@ class ChainTest extends TestCase
|
||||
|
||||
public function testCanRequestKeyInFastStorage()
|
||||
{
|
||||
$uri = $this->createMock('Psr\Http\Message\UriInterface');
|
||||
$uri = $this->createMock(UriInterface::class);
|
||||
$uri->method('getPath')->willReturn('/foo/bar');
|
||||
$uri->method('getQuery')->willReturn('index=1');
|
||||
|
||||
$request = $this->createMock('Psr\Http\Message\RequestInterface');
|
||||
$request = $this->createMock(RequestInterface::class);
|
||||
$request->method('getMethod')
|
||||
->willReturn('GET');
|
||||
$request->method('getUri')->willReturn($uri);
|
||||
@@ -38,11 +41,11 @@ class ChainTest extends TestCase
|
||||
|
||||
public function testCanRequestKeyInSlowStorage()
|
||||
{
|
||||
$uri = $this->createMock('Psr\Http\Message\UriInterface');
|
||||
$uri = $this->createMock(UriInterface::class);
|
||||
$uri->method('getPath')->willReturn('/foo/baz');
|
||||
$uri->method('getQuery')->willReturn('');
|
||||
|
||||
$request = $this->createMock('Psr\Http\Message\RequestInterface');
|
||||
$request = $this->createMock(RequestInterface::class);
|
||||
$request->method('getMethod')
|
||||
->willReturn('GET');
|
||||
$request->method('getUri')->willReturn($uri);
|
||||
|
@@ -2,25 +2,27 @@
|
||||
|
||||
namespace DesignPatterns\Behavioral\Observer;
|
||||
|
||||
use SplSubject;
|
||||
|
||||
class UserObserver implements \SplObserver
|
||||
{
|
||||
/**
|
||||
* @var User[]
|
||||
* @var SplSubject[]
|
||||
*/
|
||||
private $changedUsers = [];
|
||||
|
||||
/**
|
||||
* It is called by the Subject, usually by SplSubject::notify()
|
||||
*
|
||||
* @param \SplSubject $subject
|
||||
* @param SplSubject $subject
|
||||
*/
|
||||
public function update(\SplSubject $subject)
|
||||
public function update(SplSubject $subject)
|
||||
{
|
||||
$this->changedUsers[] = clone $subject;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return User[]
|
||||
* @return SplSubject[]
|
||||
*/
|
||||
public function getChangedUsers(): array
|
||||
{
|
||||
|
@@ -10,7 +10,7 @@ class AndSpecification implements Specification
|
||||
private $specifications;
|
||||
|
||||
/**
|
||||
* @param Specification[] ...$specifications
|
||||
* @param Specification[] $specifications
|
||||
*/
|
||||
public function __construct(Specification ...$specifications)
|
||||
{
|
||||
|
@@ -10,14 +10,14 @@ class OrSpecification implements Specification
|
||||
private $specifications;
|
||||
|
||||
/**
|
||||
* @param Specification[] ...$specifications
|
||||
* @param Specification[] $specifications
|
||||
*/
|
||||
public function __construct(Specification ...$specifications)
|
||||
{
|
||||
$this->specifications = $specifications;
|
||||
}
|
||||
|
||||
/**
|
||||
/*
|
||||
* if at least one specification is true, return true, else return false
|
||||
*/
|
||||
public function isSatisfiedBy(Item $item): bool
|
||||
|
Reference in New Issue
Block a user