Skip to content

Commit

Permalink
Code clean-up
Browse files Browse the repository at this point in the history
  • Loading branch information
distantnative committed Nov 21, 2022
1 parent c6a4b88 commit a624a01
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
20 changes: 14 additions & 6 deletions src/Kql/Kql.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,11 @@ public static function run($input, $model = null)
return static::select($result, $select, $options);
}

public static function select($data, $select, array $options = [])
{
public static function select(
$data,
array|string|null $select = null,
array $options = []
) {
if ($select === null) {
return static::render($data);
}
Expand Down Expand Up @@ -159,8 +162,11 @@ public static function selectFromArray(array $array, array $select): array
/**
* @internal
*/
public static function selectFromCollection(Collection $collection, array|string $select, array $options = [])
{
public static function selectFromCollection(
Collection $collection,
array|string $select,
array $options = []
): array {
if ($options['pagination'] ?? false) {
$collection = $collection->paginate($options['pagination']);
}
Expand Down Expand Up @@ -190,8 +196,10 @@ public static function selectFromCollection(Collection $collection, array|string
/**
* @internal
*/
public static function selectFromObject(object $object, array|string $select)
{
public static function selectFromObject(
object $object,
array|string $select
): array {
// replace actual object with intercepting proxy class
$object = Interceptor::replace($object);
$result = [];
Expand Down
2 changes: 1 addition & 1 deletion tests/Kql/KqlTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ public function testRunForbiddenMethod()
public function testSelect()
{
// no select, returns data via ::render
$result = Kql::select('foo', null);
$result = Kql::select('foo');
$this->assertSame('foo', $result);

// help
Expand Down

0 comments on commit a624a01

Please sign in to comment.