Last active
June 20, 2020 23:02
-
-
Save midnite81/9b0c2b063908568749ae86e036e3055b to your computer and use it in GitHub Desktop.
A small accounting class for demonstration
This file contains hidden or 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 App\Services; | |
class Accounting | |
{ | |
/** | |
* Calculate the margin | |
* | |
* @param $buyAtFigure | |
* @param $sellAtFigure | |
* @param int $round | |
* @return float | |
*/ | |
public static function margin($buyAtFigure, $sellAtFigure, $round = 2) | |
{ | |
return round((($sellAtFigure - $buyAtFigure) / $sellAtFigure) * 100, $round); | |
} | |
/** | |
* Calculate the markup | |
* | |
* @param $buyAtFigure | |
* @param $sellAtFigure | |
* @param int $round | |
* @return float | |
*/ | |
public static function markup($buyAtFigure, $sellAtFigure, $round = 2) | |
{ | |
return round((($sellAtFigure - $buyAtFigure) / $buyAtFigure) * 100, $round); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment