Skip to content

Instantly share code, notes, and snippets.

@reginaldojunior
Created January 13, 2018 15:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save reginaldojunior/052bbc1e1d853abab8b74df2df4238d1 to your computer and use it in GitHub Desktop.
Save reginaldojunior/052bbc1e1d853abab8b74df2df4238d1 to your computer and use it in GitHub Desktop.
Calc.php
<?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