nur-sery/nur_tests/mapper/base/impl/Add2Mapper.php

20 lines
437 B
PHP
Raw Normal View History

2024-04-04 16:26:22 +04:00
<?php
namespace nur\mapper\base\impl;
use nur\mapper\base\Mapper;
class Add2Mapper extends Mapper {
function __construct(int $a, ?int $b = null, ?int $c = null, ?iterable $source = null) {
parent::__construct($source);
$amount = $a;
if ($b !== null) $amount += $b;
if ($c !== null) $amount += $c;
$this->amount = $amount;
}
private $amount;
function mapper($item) {
return $item + $this->amount;
}
}