We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
| 1 | <?php  | 
            ||
| 25 | final class Formatter  | 
            ||
| 26 | { | 
            ||
| 27 | /**  | 
            ||
| 28 | * @var int  | 
            ||
| 29 | */  | 
            ||
| 30 | private $maxDepth;  | 
            ||
| 31 | |||
| 32 | /**  | 
            ||
| 33 | * @var int  | 
            ||
| 34 | */  | 
            ||
| 35 | private $maxChildren;  | 
            ||
| 36 | |||
| 37 | /**  | 
            ||
| 38 | * Initializes the message creator.  | 
            ||
| 39 | *  | 
            ||
| 40 | * @param int $maxDepth Maximum depth level to show when normalizing data  | 
            ||
| 41 | * @param int $maxChildren Maximum children level to show when normalizing data  | 
            ||
| 42 | */  | 
            ||
| 43 | public function __construct(int $maxDepth, int $maxChildren)  | 
            ||
| 48 | |||
| 49 | /**  | 
            ||
| 50 | * Creates a message based on a result and some templates.  | 
            ||
| 51 | *  | 
            ||
| 52 | * @param mixed $input  | 
            ||
| 53 | * @param array $properties  | 
            ||
| 54 | * @param string $template  | 
            ||
| 55 | *  | 
            ||
| 56 | * @return string  | 
            ||
| 57 | */  | 
            ||
| 58 | public function create($input, array $properties, string $template): string  | 
            ||
| 59 |     { | 
            ||
| 60 | $properties += ['placeholder' => $this->normalize($input)];  | 
            ||
| 61 | |||
| 62 | return preg_replace_callback(  | 
            ||
| 63 |             '/{{(\w+)}}/', | 
            ||
| 64 |             function ($matches) use ($properties) { | 
            ||
| 65 | $value = $matches[0];  | 
            ||
| 66 |                 if (array_key_exists($matches[1], $properties)) { | 
            ||
| 67 | $value = $properties[$matches[1]];  | 
            ||
| 68 | }  | 
            ||
| 69 | |||
| 70 |                 if ($matches[1] === 'placeholder' && is_string($value)) { | 
            ||
| 71 | return $value;  | 
            ||
| 72 | }  | 
            ||
| 73 | |||
| 74 | return $this->normalize($value);  | 
            ||
| 75 | },  | 
            ||
| 76 | $template  | 
            ||
| 77 | );  | 
            ||
| 78 | }  | 
            ||
| 79 | |||
| 80 | private function quoteCode(string $string, $currentDepth): string  | 
            ||
| 88 | |||
| 89 | private function normalize($raw, int $currentDepth = 0): string  | 
            ||
| 113 | |||
| 114 | private function normalizeObject($object, int $currentDepth): string  | 
            ||
| 147 | |||
| 148 | private function normalizeException(Exception $exception, int $currentDepth): string  | 
            ||
| 158 | |||
| 159 | private function normalizeArray(array $array, int $currentDepth): string  | 
            ||
| 192 | |||
| 193 | private function normalizeFloat(float $float, int $currentDepth): string  | 
            ||
| 205 | |||
| 206 | private function normalizeResource($raw, int $currentDepth): string  | 
            ||
| 210 | |||
| 211 | private function normalizeBool(bool $raw, int $currentDepth): string  | 
            ||
| 215 | }  | 
            ||
| 216 |