Skip to content

Instantly share code, notes, and snippets.

@vahid-almasi
Last active December 22, 2018 10:58
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 vahid-almasi/657ddcd7d17e02bc8bf1eea0bb2b1346 to your computer and use it in GitHub Desktop.
Save vahid-almasi/657ddcd7d17e02bc8bf1eea0bb2b1346 to your computer and use it in GitHub Desktop.
<?
public function sum() {
foreach($this->shapes as $shape) {
if(is_a($shape, 'Square')) {
$area[] = pow($shape->length, 2);
} else if(is_a($shape, 'Circle')) {
$area[] = pi() * pow($shape->radius, 2);
}
}
return array_sum($area);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment