39 lines
725 B
PHP
39 lines
725 B
PHP
<?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));
|
|
}
|
|
|
|
|
|
}
|