-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from chadicus/fea/unique
Add Arrays::unique()
- Loading branch information
Showing
5 changed files
with
146 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
|
||
namespace TraderInteractive\Filter\Exceptions; | ||
|
||
use TraderInteractive\Exceptions\FilterException; | ||
|
||
class DuplicateValuesException extends FilterException | ||
{ | ||
/** | ||
* @var string | ||
*/ | ||
const ERROR_FORMAT = "Array contains the following duplicate values: %s"; | ||
|
||
/** | ||
* @param array $duplicateValues The duplicate values found in the array. | ||
*/ | ||
public function __construct(array $duplicateValues) | ||
{ | ||
$message = sprintf(self::ERROR_FORMAT, var_export($duplicateValues, true)); | ||
parent::__construct($message); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?php | ||
|
||
namespace Exceptions; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
use TraderInteractive\Filter\Exceptions\DuplicateValuesException; | ||
|
||
/** | ||
* @coversDefaultClass \TraderInteractive\Filter\Exceptions\DuplicateValuesException | ||
*/ | ||
final class DuplicateValuesExceptionTest extends TestCase | ||
{ | ||
/** | ||
* @test | ||
* @covers ::__construct | ||
*/ | ||
public function basicUsage() | ||
{ | ||
$duplicates = ['foo', 'bar']; | ||
$exception = new DuplicateValuesException($duplicates); | ||
$this->assertSame( | ||
sprintf(DuplicateValuesException::ERROR_FORMAT, var_export($duplicates, true)), | ||
$exception->getMessage() | ||
); | ||
} | ||
} |