<?php

namespace App\ClassLib;

class PayrollComputation
{
    public function __construct()
    {
    }

    public function computeIncomeTax($grossTaxableIncome)
    {
        $tax = 0;
        if($grossTaxableIncome <= 10417)
        {
            $tax = 0;
        }
        else if($grossTaxableIncome <= 16666)
        {
            $tax = ($grossTaxableIncome - 10417) * 0.2;
        }
        else if($grossTaxableIncome <= 33332)
        {
            $tax = (($grossTaxableIncome - 16667) * 0.25) + 1250;
        }
        else if($grossTaxableIncome <= 83332)
        {
            $tax = (($grossTaxableIncome - 33333) * 0.3) + 5416.67;
        }
        else if($grossTaxableIncome <= 333332)
        {
            $tax = (($grossTaxableIncome - 83333) * 0.32) + 20416.67;
        }
        else
        {
            $tax = (($grossTaxableIncome - 333333) * 0.35) + 100416.67;
        }

        return $tax;
    }
}