Skip to content

Commit

Permalink
fixed functions tests coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
FacedSID committed Nov 17, 2018
1 parent 22bf561 commit c84c630
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions src/functions.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,49 @@
<?php

// @codeCoverageIgnoreStart
if (! function_exists('tap')) {
/**
* Call the given Closure with the given value then return the value.
*
* @param mixed $value
* @param callable $callback
*
* @return mixed
*/
function tap($value, $callback)
{
$callback($value);

return $value;
}
}
// @codeCoverageIgnoreEnd

// @codeCoverageIgnoreStart
if (! function_exists('array_flatten')) {
/**
* Flatten a multi-dimensional array into a single level.
*
* @param array $array
* @param int $depth
*
* @return array
*/
function array_flatten($array, $depth = INF): array
{
return array_reduce($array, function ($result, $item) use ($depth) {
if (! is_array($item)) {
return array_merge($result, [$item]);
} elseif ($depth === 1) {
return array_merge($result, array_values($item));
} else {
return array_merge($result, array_flatten($item, $depth - 1));
}
}, []);
}
}
// @codeCoverageIgnoreEnd

if (! function_exists('raw')) {
/**
* Wrap string into Expression object for inserting in sql query as is.
Expand Down

0 comments on commit c84c630

Please sign in to comment.