Skip to content

Instantly share code, notes, and snippets.

@midnite81
Last active June 20, 2020 23:02
Show Gist options
  • Save midnite81/9b0c2b063908568749ae86e036e3055b to your computer and use it in GitHub Desktop.
Save midnite81/9b0c2b063908568749ae86e036e3055b to your computer and use it in GitHub Desktop.
A small accounting class for demonstration
<?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