for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Digia\GraphQL\Util;
const MAX_LENGTH = 5;
/**
* Given `[A, B, C]` returns `'A, B or C'`.
*
* @param array $items
* @return string
*/
function orList(array $items): string
{
$selected = \array_slice($items, 0, MAX_LENGTH);
$allButLast = \array_slice($selected, 0, -1);
return implode(', ', $allButLast) . ' or ' . $selected[\count($selected) - 1];
}
* Given `[A, B, C]` returns `'"A", "B" or "C"'`.
function quotedOrList(array $items): string
return orList(array_map(function ($item) {
return '"' . $item . '"';
}, $items));