Created
December 21, 2018 03:03
-
-
Save vahid-almasi/8cdee8bc20e05b28b32d78bba7a889e5 to your computer and use it in GitHub Desktop.
This file contains 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
<? | |
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