Skip to content

Instantly share code, notes, and snippets.

@vahid-almasi
Created December 21, 2018 03:03
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/8cdee8bc20e05b28b32d78bba7a889e5 to your computer and use it in GitHub Desktop.
Save vahid-almasi/8cdee8bc20e05b28b32d78bba7a889e5 to your computer and use it in GitHub Desktop.
<?
class SumCalculatorOutputter {
protected $calculator;
public function __constructor(AreaCalculator $calculator) {
$this->calculator = $calculator;
}
public function JSON() {
$data = array(
'sum' => $this->calculator->sum();
);
return json_encode($data);
}
public function HTML() {
return implode('', array(
'',
'Sum of the areas of provided shapes: ',
$this->calculator->sum(),
''
));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment