init
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace Lucent\Primitive;
|
||||
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
/**
|
||||
* @extends \Illuminate\Support\Collection<int|string, string>
|
||||
*/
|
||||
final class StringCollection extends Collection
|
||||
{
|
||||
|
||||
public function __construct(
|
||||
string ...$array
|
||||
) {
|
||||
parent::__construct($array);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string[]
|
||||
**/
|
||||
public function toArray(): array
|
||||
{
|
||||
return collect($this)->values()->toArray();
|
||||
}
|
||||
|
||||
public static function fromArray(array $data): StringCollection
|
||||
{
|
||||
return new StringCollection(...$data);
|
||||
}
|
||||
|
||||
public static function fromDB(string $data): StringCollection
|
||||
{
|
||||
return new StringCollection(...\json_decode($data,true));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user