Created
January 13, 2018 15:27
-
-
Save reginaldojunior/052bbc1e1d853abab8b74df2df4238d1 to your computer and use it in GitHub Desktop.
Calc.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Calc | |
{ | |
private $nums; | |
public function __construct(array $nums) | |
{ | |
if (!is_array($nums)) { | |
thown new \Exception("Method wait array"); | |
} | |
$this->nums = $nums; | |
} | |
public function getResult() | |
{ | |
$result = 0; | |
foreach ($this->nums as $num) { | |
$result += $num; | |
} | |
return $result; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment