Skip to content

Instantly share code, notes, and snippets.

@polidog
Created December 8, 2020 15:59
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 polidog/b46e64a5e6a584dd7b9915efe734505f to your computer and use it in GitHub Desktop.
Save polidog/b46e64a5e6a584dd7b9915efe734505f to your computer and use it in GitHub Desktop.
<?php
class FurusatoTax
{
private int $donationPrice;
private float $incomeTaxRate;
/**
* FurusatoTax constructor.
* @param int $donationPrice
* @param float $incomeTaxRate
*/
public function __construct(int $donationPrice, float $incomeTaxRate)
{
$this->donationPrice = $donationPrice;
$this->incomeTaxRate = $incomeTaxRate;
}
public function __invoke(): int
{
return $this->deductionByIncome() + $this->deductionBaseResidentTax() + $this->deductionSpecialResidentTax();
}
public function deductionByIncome(): int
{
return ($this->donationPrice - 2000) * $this->incomeTaxRate;
}
public function deductionBaseResidentTax(): int
{
return ($this->donationPrice - 2000) * 0.1;
}
public function deductionSpecialResidentTax(): int
{
return ($this->donationPrice - 2000) * (1 - 0.1) - $this->incomeTaxRate;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment