Skip to content

Commit

Permalink
replace exception
Browse files Browse the repository at this point in the history
  • Loading branch information
Enjoyzz committed Jul 29, 2021
1 parent 7912db0 commit 054509f
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 60 deletions.
57 changes: 0 additions & 57 deletions example/example.php

This file was deleted.

5 changes: 3 additions & 2 deletions src/CollectStrategy/StrategyFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Enjoys\AssetsCollector\CollectStrategy\Strategy\ManyFilesStrategy;
use Enjoys\AssetsCollector\CollectStrategy\Strategy\OneFileStrategy;
use Enjoys\AssetsCollector\Environment;
use Enjoys\AssetsCollector\Exception\UnexpectedParameters;

class StrategyFactory
{
Expand All @@ -21,7 +22,7 @@ class StrategyFactory
* @param array<Asset> $assetsCollection
* @param string $type
* @return StrategyInterface
* @throws \Exception
* @throws UnexpectedParameters
*/
public static function getStrategy(
Environment $environment,
Expand All @@ -30,7 +31,7 @@ public static function getStrategy(
): StrategyInterface {
$strategy = $environment->getStrategy();
if (!isset(self::STRATEGY[$strategy])) {
throw new \Exception('Invalid strategy');
throw new UnexpectedParameters('Invalid strategy');
}
$strategyClass = self::STRATEGY[$strategy];

Expand Down
3 changes: 2 additions & 1 deletion tests/CollectStrategy/StrategyFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Enjoys\AssetsCollector\CollectStrategy\StrategyFactory;
use Enjoys\AssetsCollector\CollectStrategy\StrategyInterface;
use Enjoys\AssetsCollector\Environment;
use Enjoys\AssetsCollector\Exception\UnexpectedParameters;
use PHPUnit\Framework\TestCase;

class StrategyFactoryTest extends TestCase
Expand Down Expand Up @@ -47,7 +48,7 @@ public function testStrategyFactoryGood()

public function testStrategyFactoryFail()
{
$this->expectException(\Exception::class);
$this->expectException(UnexpectedParameters::class);
$environment = $this->getMockBuilder(Environment::class)
->onlyMethods(['getStrategy'])
->getMock();
Expand Down

0 comments on commit 054509f

Please sign in to comment.