20 lines
303 B
PHP
20 lines
303 B
PHP
|
<?php
|
||
|
namespace nur\mapper\base\impl;
|
||
|
|
||
|
use nur\mapper\base\Mapper;
|
||
|
|
||
|
class ReduceMapper extends Mapper {
|
||
|
private static $sum;
|
||
|
|
||
|
static function sum(): int {
|
||
|
return self::$sum;
|
||
|
}
|
||
|
|
||
|
function setup(): void {
|
||
|
self::$sum = 0;
|
||
|
}
|
||
|
|
||
|
function mapper($item) {
|
||
|
return self::$sum += $item;
|
||
|
}
|
||
|
}
|