Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?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;
- }
- }
Add Comment
Please, Sign In to add comment