Skip to content

Commit

Permalink
Align code to coding standard
Browse files Browse the repository at this point in the history
  • Loading branch information
Giuffre committed Jun 27, 2017
1 parent bd0b799 commit 2a15c34
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 56 deletions.
18 changes: 9 additions & 9 deletions src/Moka/Factory/ProxyBuilderFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,12 @@ public static function get(MockingStrategyInterface $mockingStrategy): ProxyBuil
}

/**
* @return void
* @param MockingStrategyInterface $mockingStrategy
* @return string
*/
public static function reset()
private static function key(MockingStrategyInterface $mockingStrategy): string
{
foreach (self::$mockBuilders as $mockBuilder) {
$mockBuilder->reset();
}
return get_class($mockingStrategy);
}

/**
Expand All @@ -51,11 +50,12 @@ protected static function build(MockingStrategyInterface $mockingStrategy): Prox
}

/**
* @param MockingStrategyInterface $mockingStrategy
* @return string
* @return void
*/
private static function key(MockingStrategyInterface $mockingStrategy): string
public static function reset()
{
return get_class($mockingStrategy);
foreach (self::$mockBuilders as $mockBuilder) {
$mockBuilder->reset();
}
}
}
85 changes: 42 additions & 43 deletions src/Moka/Strategy/AbstractMockingStrategy.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
use Moka\Exception\NotImplementedException;
use Moka\Factory\StubFactory;
use Moka\Stub\Stub;
use Moka\Stub\StubSet;

/**
* Class AbstractMockingStrategy
Expand Down Expand Up @@ -62,6 +61,12 @@ public function build(string $fqcn)
}
}

/**
* @param string $fqcn
* @return object
*/
abstract protected function doBuild(string $fqcn);

/**
* @param object $mock
* @param array $stubs
Expand All @@ -79,40 +84,6 @@ public function decorate($mock, array $stubs)
}
}

/**
* @param object $mock
* @return object
*
* @throws NotImplementedException
* @throws InvalidArgumentException
*/
public function get($mock)
{
$this->checkMockType($mock);

return $this->doGet($mock);
}

/**
* @return string
*
* @throws NotImplementedException
*/
public function getMockType(): string
{
$this->verifyMockType();

return $this->mockType;
}

/**
* @param string $fqcn
*/
final protected function setMockType(string $fqcn)
{
$this->mockType = $fqcn;
}

/**
* @param object $mock
*
Expand All @@ -135,10 +106,16 @@ final protected function checkMockType($mock)
}

/**
* @param string $fqcn
* @return object
* @return void
*
* @throws NotImplementedException
*/
abstract protected function doBuild(string $fqcn);
private function verifyMockType()
{
if (!$this->mockType) {
throw new NotImplementedException('Mock type was not defined');
}
}

/**
* @param object $mock
Expand All @@ -147,21 +124,43 @@ abstract protected function doBuild(string $fqcn);
*/
abstract protected function doDecorate($mock, Stub $stub);

/**
* @param object $mock
* @return object
*
* @throws NotImplementedException
* @throws InvalidArgumentException
*/
public function get($mock)
{
$this->checkMockType($mock);

return $this->doGet($mock);
}

/**
* @param object $mock
* @return object
*/
abstract protected function doGet($mock);

/**
* @return void
* @return string
*
* @throws NotImplementedException
*/
private function verifyMockType()
public function getMockType(): string
{
if (!$this->mockType) {
throw new NotImplementedException('Mock type was not defined');
}
$this->verifyMockType();

return $this->mockType;
}

/**
* @param string $fqcn
*/
final protected function setMockType(string $fqcn)
{
$this->mockType = $fqcn;
}
}
1 change: 0 additions & 1 deletion src/Moka/Strategy/MockingStrategyInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
use Moka\Exception\InvalidArgumentException;
use Moka\Exception\MockNotCreatedException;
use Moka\Exception\NotImplementedException;
use Moka\Stub\StubSet;

/**
* Interface MockingStrategyInterface
Expand Down
3 changes: 0 additions & 3 deletions src/Moka/Tests/MokaMockingStrategyTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@
namespace Moka\Tests;

use Moka\Exception\InvalidArgumentException;
use Moka\Factory\StubFactory;
use Moka\Strategy\MockingStrategyInterface;
use Moka\Stub\Stub;
use Moka\Stub\StubSet;
use PHPUnit\Framework\TestCase;
use Tests\AbstractTestClass;
use Tests\BarTestClass;
Expand Down

0 comments on commit 2a15c34

Please sign in to comment.