- array_reduce: documentation ( source)
- var_export: documentation ( source)
<?php
class Test
{
const FLOWS_EMAIL_TYPE_ACTION = 'foo';
function __construct(array $steps)
{
$email_actions = array_reduce(
$steps,
fn($result, $step) => $result
+ (($step['settings']['type'] ?? null) === self::FLOWS_EMAIL_TYPE_ACTION),
0
);
var_export($email_actions);
}
}
new Test([
['settings' => ['type' => 'bar']],
['settings' => ['type' => 'foo']],
[],
['settings' => ['type' => 'foo']],
]);