-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDivide.php
More file actions
40 lines (35 loc) · 1.05 KB
/
Divide.php
File metadata and controls
40 lines (35 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?php
/**
* Data Mapper (https://github.com/mozahran/data-mapper)
* Copyright 2021, Mohamed Zahran. (https://www.linkedin.com/in/mo-zahran/)
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright (c) Mohamed Zahran (https://www.linkedin.com/in/mo-zahran/)
* @link https://github.com/mozahran/data-mapper
* @license https://opensource.org/licenses/mit-license.php MIT License
*/
namespace Zahran\Mapper\Mutator;
use Zahran\Mapper\Contract\Mutator as MutatorInterface;
use Zahran\Mapper\Model\Mutator;
class Divide implements MutatorInterface
{
/**
* @var Mutator
*/
protected $model;
public function setModel(Mutator $model): MutatorInterface
{
$this->model = $model;
return $this;
}
public function apply($originalValue, array $arguments = [])
{
$newValue = $originalValue;
for($i=0; $i < count($arguments); $i++) {
$newValue /= $arguments[$i];
}
return $newValue;
}
}