-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add Subset and SubsetCollection classes
- Loading branch information
Showing
5 changed files
with
126 additions
and
69 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?php | ||
|
||
namespace Ozdemir\SubsetFinder; | ||
|
||
class Subset | ||
{ | ||
public array $items; | ||
public int $quantity; | ||
|
||
/** | ||
* Subset constructor. | ||
* | ||
* @param array $items | ||
* @param int $quantity | ||
*/ | ||
public function __construct(array $items, int $quantity = 1) | ||
{ | ||
$this->items = $items; | ||
$this->quantity = $quantity; | ||
} | ||
|
||
/** | ||
* Create a new instance of Subset with the given items. | ||
* | ||
* @param array $items | ||
* @return self | ||
*/ | ||
public static function of(array $items): self | ||
{ | ||
return new static($items); | ||
} | ||
|
||
/** | ||
* Create a new instance of Subset with the given items and quantity. | ||
* | ||
* @param int $quantity | ||
* @return $this | ||
*/ | ||
public function take(int $quantity): self | ||
{ | ||
return new static($this->items, $quantity); | ||
} | ||
} |
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,13 @@ | ||
<?php | ||
|
||
namespace Ozdemir\SubsetFinder; | ||
|
||
use Illuminate\Support\Collection; | ||
|
||
|
||
class SubsetCollection extends Collection | ||
{ | ||
|
||
} | ||
|
||
|
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
Oops, something went wrong.