Skip to content

Commit 3e1990c

Browse files
authored
2.2.0 dev (#7)
* Adds support for from() * Test only php 7.1
1 parent 76b718b commit 3e1990c

File tree

71 files changed

+356
-718
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+356
-718
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
.idea
22
composer.lock
33
TestReport
4-
vendor
4+
vendor
5+
.php_cs.cache

.travis.yml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,7 @@ language: php
33
matrix:
44
fast_finish: true
55
include:
6-
- php: 5.6
7-
- php: 7.0
86
- php: 7.1
9-
- php: hhvm
107

118
sudo: false
129

@@ -20,6 +17,5 @@ install:
2017
- composer install
2118

2219
script:
23-
- vendor/bin/php-cs-fixer --diff --dry-run -v fix Exceptions
24-
- vendor/bin/php-cs-fixer --diff --dry-run -v fix Tests
25-
- vendor/bin/phpunit
20+
- composer lint
21+
- composer test

Exceptions/Collection/CollectionException.php

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,32 @@
22

33
namespace Exceptions\Collection;
44

5+
use Exceptions\Helpers\DefaultsInterface;
6+
use Exceptions\Helpers\FromException;
7+
58
/**
69
* This is a tag like class that is used to regroup all Collection exceptions under a single base class.
710
*
8-
* @author Mathieu Dumoulin aka CrazyCodr <[email protected]>
11+
* @author Mathieu Dumoulin <[email protected]>
912
* @license MIT
1013
*/
11-
abstract class CollectionException extends \RuntimeException implements CollectionExceptionInterface
14+
abstract class CollectionException extends \RuntimeException implements CollectionExceptionInterface, DefaultsInterface
1215
{
16+
use FromException;
17+
18+
/**
19+
* {@inheritdoc}
20+
*/
21+
public static function getDefaultMessage(): string
22+
{
23+
return static::MESSAGE;
24+
}
25+
26+
/**
27+
* {@inheritdoc}
28+
*/
29+
public static function getDefaultCode(): int
30+
{
31+
return static::CODE;
32+
}
1333
}

Exceptions/Collection/CollectionExceptionInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
/**
66
* This interface defines the different accessor you can use when dealing with Collection exceptions.
77
*
8-
* @author Mathieu Dumoulin aka CrazyCodr <[email protected]>
8+
* @author Mathieu Dumoulin <[email protected]>
99
* @license MIT
1010
*/
1111
interface CollectionExceptionInterface

Exceptions/Collection/EmptyException.php

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,11 @@
55
/**
66
* Use this exception when an operation on a collection cannot be achieved because the array is already empty.
77
*
8-
* @author Mathieu Dumoulin aka CrazyCodr <[email protected]>
8+
* @author Mathieu Dumoulin <[email protected]>
99
* @license MIT
1010
*/
1111
class EmptyException extends CollectionException
1212
{
13-
public function __construct(
14-
$message = 'Array/collection is currently empty',
15-
$code = 0,
16-
$previous = null
17-
) {
18-
parent::__construct($message, $code, $previous);
19-
}
13+
const MESSAGE = 'Array/collection is currently empty';
14+
const CODE = 0;
2015
}

Exceptions/Collection/FullException.php

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,11 @@
66
* Use this exception when an operation on a collection cannot be achieved because the array has already reached it's
77
* limit and cannot accept more data.
88
*
9-
* @author Mathieu Dumoulin aka CrazyCodr <[email protected]>
9+
* @author Mathieu Dumoulin <[email protected]>
1010
* @license MIT
1111
*/
1212
class FullException extends CollectionException
1313
{
14-
public function __construct(
15-
$message = 'Cannot add items to array/collection, it is already full',
16-
$code = 0,
17-
$previous = null
18-
) {
19-
parent::__construct($message, $code, $previous);
20-
}
14+
const MESSAGE = 'Cannot add items to array/collection, it is already full';
15+
const CODE = 0;
2116
}

Exceptions/Collection/KeyAlreadyExistsException.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,11 @@
66
* Use this exception when an operation on a collection tries to add an element using a key that already exists in the
77
* collection of items.
88
*
9-
* @author Mathieu Dumoulin aka CrazyCodr <[email protected]>
9+
* @author Mathieu Dumoulin <[email protected]>
1010
* @license MIT
1111
*/
1212
class KeyAlreadyExistsException extends CollectionException
1313
{
14-
public function __construct($message = 'Key already exists in array/collection', $code = 0, $previous = null)
15-
{
16-
parent::__construct($message, $code, $previous);
17-
}
14+
const MESSAGE = 'Key already exists in array/collection';
15+
const CODE = 0;
1816
}

Exceptions/Collection/KeyNotFoundException.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,11 @@
1212
* specifically a collection/array like structure that lives in memory. When querying a filesystem, use the
1313
* filesystem exceptions, when querying a data source use the data exceptions, etc.
1414
*
15-
* @author Mathieu Dumoulin aka CrazyCodr <[email protected]>
15+
* @author Mathieu Dumoulin <[email protected]>
1616
* @license MIT
1717
*/
1818
class KeyNotFoundException extends CollectionException implements NotFoundException
1919
{
20-
public function __construct($message = 'Key not found in array/collection', $code = 0, $previous = null)
21-
{
22-
parent::__construct($message, $code, $previous);
23-
}
20+
const MESSAGE = 'Key not found in array/collection';
21+
const CODE = 0;
2422
}

Exceptions/Collection/ReadOnlyArrayException.php

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,11 @@
66
* Use this exception when an operation on a collection that is locked/read-only tries to modify the collection of
77
* items.
88
*
9-
* @author Mathieu Dumoulin aka CrazyCodr <[email protected]>
9+
* @author Mathieu Dumoulin <[email protected]>
1010
* @license MIT
1111
*/
1212
class ReadOnlyArrayException extends CollectionException
1313
{
14-
public function __construct(
15-
$message = 'Array/Collection is read-only, you cannot alter it',
16-
$code = 0,
17-
$previous = null
18-
) {
19-
parent::__construct($message, $code, $previous);
20-
}
14+
const MESSAGE = 'Array/Collection is read-only, you cannot alter it';
15+
const CODE = 0;
2116
}

Exceptions/Collection/ReadOnlyArrayItemException.php

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,11 @@
66
* Use this exception when an operation on a collection item that is locked/read-only tries to modify the item in
77
* question.
88
*
9-
* @author Mathieu Dumoulin aka CrazyCodr <[email protected]>
9+
* @author Mathieu Dumoulin <[email protected]>
1010
* @license MIT
1111
*/
1212
class ReadOnlyArrayItemException extends CollectionException
1313
{
14-
public function __construct(
15-
$message = 'Array/Collection item is read-only, you cannot modify it',
16-
$code = 0,
17-
$previous = null
18-
) {
19-
parent::__construct($message, $code, $previous);
20-
}
14+
const MESSAGE = 'Array/Collection item is read-only, you cannot modify it';
15+
const CODE = 0;
2116
}

0 commit comments

Comments
 (0)