-
Notifications
You must be signed in to change notification settings - Fork 5
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 seboettg/improvements
Further improvements
- Loading branch information
Showing
13 changed files
with
93 additions
and
32 deletions.
There are no files selected for viewing
Binary file not shown.
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 |
---|---|---|
|
@@ -16,9 +16,6 @@ | |
* | ||
* This interface imposes a total ordering on the objects of each class that implements it. This ordering is referred | ||
* to as the class's natural ordering, and the class's compareTo method is referred to as its natural comparison method. | ||
* | ||
* @package Seboettg\Collection | ||
* @author Sebastian Böttger <[email protected]> | ||
*/ | ||
interface Comparable | ||
{ | ||
|
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 |
---|---|---|
@@ -1,4 +1,13 @@ | ||
<?php | ||
declare(strict_types=1); | ||
/* | ||
* Copyright (C) 2022 Sebastian Böttger <[email protected]> | ||
* You may use, distribute and modify this code under the | ||
* terms of the MIT license. | ||
* | ||
* You should have received a copy of the MIT license with | ||
* this file. If not, please visit: https://opensource.org/licenses/mit-license.php | ||
*/ | ||
|
||
namespace Seboettg\Collection\Lists; | ||
|
||
|
@@ -32,21 +41,33 @@ public static function isList($value): bool | |
} | ||
} | ||
|
||
/** | ||
* Returns an implmentation of `ListInterface` with no entries. | ||
*/ | ||
function emptyList(): ListInterface | ||
{ | ||
return Functions::emptyList(); | ||
} | ||
|
||
/** | ||
* Returns an implementation of `ListInterface` containing passed elements | ||
*/ | ||
function listOf(...$elements): ListInterface | ||
{ | ||
return Functions::listOf(...$elements); | ||
} | ||
|
||
/** | ||
* Returns an implementation of `ListInterface` containing all values of the passed array. The array keys are discarded. | ||
*/ | ||
function listFromArray(array $elements): ListInterface | ||
{ | ||
return Functions::listFromArray($elements); | ||
} | ||
|
||
/** | ||
* Returns true when `$value` is an instance of `ListInterface`, otherwise false. | ||
*/ | ||
function isList($value): bool | ||
{ | ||
return Functions::isList($value); | ||
|
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 |
---|---|---|
@@ -1,4 +1,12 @@ | ||
<?php | ||
/* | ||
* Copyright (C) 2016 Sebastian Böttger <[email protected]> | ||
* You may use, distribute and modify this code under the | ||
* terms of the MIT license. | ||
* | ||
* You should have received a copy of the MIT license with | ||
* this file. If not, please visit: https://opensource.org/licenses/mit-license.php | ||
*/ | ||
|
||
namespace Seboettg\Collection\Lists\ListFeatures; | ||
|
||
|
@@ -33,4 +41,4 @@ public function plus(iterable $elements): ListInterface; | |
* @return ListInterface | ||
*/ | ||
public function intersect(ListInterface $other): ListInterface; | ||
} | ||
} |
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 |
---|---|---|
@@ -1,16 +1,27 @@ | ||
<?php | ||
/* | ||
* Copyright (C) 2022 Sebastian Böttger <[email protected]> | ||
* You may use, distribute and modify this code under the | ||
* terms of the MIT license. | ||
* | ||
* You should have received a copy of the MIT license with | ||
* this file. If not, please visit: https://opensource.org/licenses/mit-license.php | ||
*/ | ||
|
||
namespace Seboettg\Collection\Lists\ListFeatures; | ||
|
||
use Seboettg\Collection\Lists\ListInterface; | ||
use function Seboettg\Collection\Lists\emptyList; | ||
use function Seboettg\Collection\Lists\listOf; | ||
|
||
/** | ||
* @property array $array | ||
*/ | ||
trait ListOperationsTrait | ||
{ | ||
|
||
|
||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
public function plus(iterable $other): ListInterface | ||
{ | ||
$list = listOf(...$this->array); | ||
|
@@ -51,4 +62,4 @@ public function intersect(ListInterface $list): ListInterface | |
} | ||
return $result; | ||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
<?php | ||
declare(strict_types=1); | ||
/* | ||
* Copyright (C) 2016 Sebastian Böttger <[email protected]> | ||
* You may use, distribute and modify this code under the | ||
|
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