Supported Versions: PHP 4 >= 4.0.5, PHP 5, PHP 7, PHP 8
Iteratively reduce the array to a single value using a callback function
<?php array_reduce(array $array, callable $callback, mixed $initial = null): mixed
<?php     protected function buildProperties(array $data)

    {

        return trim(

            array_reduce(

                $data,

                function ($output, $property) {

                    $output .= '    public $' . $property . ';' . PHP_EOL . PHP_EOL;



                    return $output;

                },

                ''

            )

        );

    }
<?php     protected function buildAssignments(array $data)

    {

        return trim(

            array_reduce(

                $data,

                function ($output, $property) {

                    $output .= '        $this->' . $property . ' = $' . $property . ';' . PHP_EOL;



                    return $output;

                },

                ''

            )

        );

    }
<?php     protected function buildRules(string $context, ValidateStatement $validateStatement)

    {

        return trim(

            array_reduce(

                $validateStatement->data(),

                function ($output, $field) use ($context) {

                    [$qualifier, $column] = $this->splitField($field);



                    if (is_null($qualifier)) {

                        $qualifier = $context;

                    }



                    $validationRules = $this->validationRules($qualifier, $column);



                    foreach ($validationRules as $name => $rule) {

                        $formattedRule = implode("', '", $rule);



                        $output .= self::INDENT . "'{$name}' => ['{$formattedRule}']," . PHP_EOL;

                    }



                    return $output;

                },

                ''

            )

        );

    }