Skip to content

Commit

Permalink
Feat: add make method to collection
Browse files Browse the repository at this point in the history
  • Loading branch information
TemKaa1337 committed Aug 12, 2024
1 parent d20fd49 commit 03b1702
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@

final class Collection implements CollectionInterface
{
public static function make(array $elements): CollectionInterface
{
return new self($elements);
}

public function __construct(
private array $elements,
) {
Expand Down
4 changes: 3 additions & 1 deletion src/Collection/CollectionInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@
use IteratorAggregate;
use Temkaa\SimpleCollections\Model\SumCriteriaInterface;

interface CollectionInterface extends ArrayableInterface,
interface CollectionInterface extends
ArrayableInterface,
Countable,
EnumerableInterface,
FilterableInterface,
FullnessInterface,
IteratorAggregate,
MakableInterface,
MappableInterface,
SortableInterface
{
Expand Down
10 changes: 10 additions & 0 deletions src/Collection/MakableInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

declare(strict_types=1);

namespace Temkaa\SimpleCollections\Collection;

interface MakableInterface
{
public static function make(array $elements): CollectionInterface;
}

0 comments on commit 03b1702

Please sign in to comment.