PHP Classes

File: CovidRelief.class.php

Recommend this page to a friend!
  Classes of Adeola Odusola   PHP Covid Relief Checks Calculator   CovidRelief.class.php   Download  
File: CovidRelief.class.php
Role: Class source
Content type: text/plain
Description: CovidRelief class file
Class: PHP Covid Relief Checks Calculator
Calculate the amount of a check as Covid-19 relief
Author: By
Last change: class name change
Date: 4 years ago
Size: 1,998 bytes
 

Contents

Class file image Download
<?php

/**
 * Description of CovidRelief
 *
 * @author Adeola.Odusola
 */
class CovidRelief {
   
    private
$cutoff=array("single"=>75000,"head_of_household"=>112500,"married"=>150000);
    private
$payout=array("single"=>1200,"head_of_household"=>1200,"married"=>2400);
    private
$status;
    private
$salary;
    private
$kids;
   
   
/**
     *
     * @param type $status
     * @param type $salary
     * @param type $kids
     * initialize filing status, salary earned, and number of children as kids
     */
   
public function __construct($status,$salary,$kids) {
       
$this->status=$status;
       
$this->salary=$salary;
       
$this->kids=$kids;
    }
   
   
/**
     *
     * @return type
     * calculate refund based on filing status, salary, and number of kids
     * if salary earned is higher than maximum allowed, $5 is deducted from every $100 earned above the allowed maximum
     */
   
public function calculateReliefCheck(){
        
//get allowed maximum salary based on status
       
$allowed_max_salary=$this->cutoff[$this->status];
       
$salary_difference=$this->salary-$allowed_max_salary;
       
// calculate refund
       
if ($salary_difference <= 0){
           
// salary is within range for full refund
            // get refund
           
$refund=$this->payout[$this->status]+($this->kids*500);
        }
        else{
           
// deduct $5 for every $100 above allowed max salary - simply 100/5 = 20 - 1:20 ratio - simply divide diff by 20
           
$loss=$salary_difference/20;
           
// check eligibility
           
$eligibility=$this->payout[$this->status]-$loss;
           
// get refund
           
$refund=$eligibility+($this->kids*500);
           
// normalize refund
           
if ($refund <=0){
               
$refund=0;
            }
        }
       
// format refund
       
$refund= number_format($refund, 2);
        return
$refund;
    }
   
}