-
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.
Merge pull request #1 from sauls/1.x
v1.1.1
- Loading branch information
Showing
13 changed files
with
304 additions
and
135 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
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 |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
/** | ||
* This file is part of the sauls/collections package. | ||
* | ||
* @author Saulius Vaičeliūnas <vaiceliunas@inbox.lt> | ||
* @link http://saulius.vaiceliunas.lt | ||
* @copyright 2018 | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Sauls\Component\Collection; | ||
|
||
interface Arrayable | ||
{ | ||
public function toArray(): array; | ||
} |
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,39 @@ | ||
<?php | ||
/** | ||
* This file is part of the sauls/collections package. | ||
* | ||
* @author Saulius Vaičeliūnas <vaiceliunas@inbox.lt> | ||
* @link http://saulius.vaiceliunas.lt | ||
* @copyright 2018 | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Sauls\Component\Collection\Converter\Type; | ||
|
||
use Sauls\Component\Collection\Arrayable; | ||
use Sauls\Component\Helper\Operation\TypeOperation\Converter\ConverterInterface; | ||
|
||
class ArrayableToArrayConverter implements ConverterInterface | ||
{ | ||
public function convert($value): array | ||
{ | ||
return $value->toArray(); | ||
} | ||
|
||
public function supports($value): bool | ||
{ | ||
return is_subclass_of($value, Arrayable::class); | ||
} | ||
|
||
public function getType(): string | ||
{ | ||
return 'array'; | ||
} | ||
|
||
public function getPriority(): int | ||
{ | ||
return 512; | ||
} | ||
} |
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,42 @@ | ||
<?php | ||
/** | ||
* This file is part of the sauls/collections package. | ||
* | ||
* @author Saulius Vaičeliūnas <vaiceliunas@inbox.lt> | ||
* @link http://saulius.vaiceliunas.lt | ||
* @copyright 2018 | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Sauls\Component\Collection\Converter\Type; | ||
|
||
use Sauls\Component\Collection\Collection; | ||
use Sauls\Component\Helper\Operation\TypeOperation\Converter\ConverterInterface; | ||
|
||
class CollectionToArrayConverter implements ConverterInterface | ||
{ | ||
/** | ||
* @param Collection $value | ||
*/ | ||
public function convert($value): array | ||
{ | ||
return $value->all(); | ||
} | ||
|
||
public function supports($value): bool | ||
{ | ||
return is_subclass_of($value, Collection::class); | ||
} | ||
|
||
public function getType(): string | ||
{ | ||
return 'array'; | ||
} | ||
|
||
public function getPriority(): int | ||
{ | ||
return 1024; | ||
} | ||
} |
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,20 @@ | ||
<?php | ||
/** | ||
* This file is part of the sauls/collections package. | ||
* | ||
* @author Saulius Vaičeliūnas <vaiceliunas@inbox.lt> | ||
* @link http://saulius.vaiceliunas.lt | ||
* @copyright 2018 | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
use function Sauls\Component\Helper\register_converters; | ||
|
||
\spl_autoload_register(function() { | ||
register_converters([ | ||
new Sauls\Component\Collection\Converter\Type\CollectionToArrayConverter, | ||
new Sauls\Component\Collection\Converter\Type\ArrayableToArrayConverter | ||
]); | ||
}); |
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.