Created
December 8, 2020 15:59
-
-
Save polidog/b46e64a5e6a584dd7b9915efe734505f to your computer and use it in GitHub Desktop.
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 | |
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