for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare(strict_types=1);
namespace Ecodev\Felix;
use GraphQL\Doctrine\Definition\EntityID;
abstract class Utility
{
/**
* Returns the short class name of any object, eg: Application\Model\Calendar => Calendar
*
* @param object|string $object
* @return string
*/
public static function getShortClassName($object): string
$reflect = new \ReflectionClass($object);
return $reflect->getShortName();
}
* Print a list of files if non empty
* @param string $title
* @param array $files
public static function printFiles(string $title, array $files): void
if (!$files) {
return;
echo $title . PHP_EOL . PHP_EOL;
foreach ($files as $file) {
echo ' ' . escapeshellarg($file) . PHP_EOL;
echo PHP_EOL;
* Replace EntityID model and don't touch other values
* @param array $data mix of objects and scalar values
* @return null|array
public static function entityIdToModel(?array $data): ?array
if ($data === null) {
$data === null
false
return null;
foreach ($data as &$value) {
if ($value instanceof EntityID) {
$value = $value->getEntity();
return $data;
public static function unique(array $array): array
$result = [];
foreach ($array as $value) {
if (!in_array($value, $result, true)) {
$result[] = $value;
return $result;