Last active
January 30, 2019 21:05
-
-
Save dez02/14019c33b3fb9cd0f22496b3ac961224 to your computer and use it in GitHub Desktop.
this is a PHP file
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
<?php | |
namespace SolvoLabs; | |
/** | |
* This class is used to realize some basic calculations. | |
* For training purposes only, use bc_math functions instead. | |
* @author Mickaël Andrieu <mickael.andrieu@solvolabs.com> | |
*/ | |
class Calculator | |
{ | |
/** | |
* @var float The result to display. | |
*/ | |
private $result; | |
/** | |
* Creates the Calculator. | |
* | |
* @param float $initialValue | |
*/ | |
public function __construct($initialValue = 0) | |
{ | |
$this->result = $initialValue; | |
} | |
/** | |
* @param float $number A number. | |
*/ | |
public function add($number) | |
{ | |
$this->result = $this->result + $number; | |
} | |
/** | |
* @param float $number A number. | |
*/ | |
public function minus($number) | |
{ | |
$this->result = $this->result - $number; | |
} | |
/** | |
* @param float $number A number. | |
*/ | |
public static function multiply($number) | |
{ | |
$this->result = $this->result * $number; | |
} | |
/** | |
* @param float $number A number. | |
*/ | |
public static function divideBy($number) | |
{ | |
$this->result = $this->result / $number; | |
} | |
/** | |
* If the object is returned, the result should be displayed. | |
* | |
* @return string | |
*/ | |
public function result() | |
{ | |
return $this->result; | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment