Skip to content

Instantly share code, notes, and snippets.

@dez02
Last active January 30, 2019 21:05
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 dez02/14019c33b3fb9cd0f22496b3ac961224 to your computer and use it in GitHub Desktop.
Save dez02/14019c33b3fb9cd0f22496b3ac961224 to your computer and use it in GitHub Desktop.
this is a PHP file
<?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