Constructor testing - using parent or not - PHP Online

Form of PHP Sandbox

Enter Your PHP code here for testing/debugging in the Online PHP Sandbox. As in the usual PHP files, you can also add HTML, but do not forget to add the tag <?php in the places where the PHP script should be executed.

Name: Constructor testing - using parent or not fullscreencopydownloadembedprint


Your result can be seen below.

Result of php executing





Full code of Constructor testing - using parent or not.php

  1. <?php
  2.  
  3. abstract class TimeEntryAbstract
  4. {
  5.     protected $queryHelper;
  6.     protected $errflag;
  7.     protected $resultMsg;
  8.     protected $orderId;
  9.     protected $groupId;
  10.     protected $dbInsert;
  11.     protected $dbValues;
  12.     protected $orderValues;
  13.     protected $candidate_id;
  14.     protected $bidAmt;
  15.     protected $otRate;
  16.     protected $holidayRate;
  17.     protected $contract_fee; //change to $contractFee when you get all the references in place
  18.     protected $total_weekly_bill; //change
  19.     protected $wp_fee; //change
  20.     protected $reg_hrs;
  21.     protected $ot_hrs;
  22.     protected $line_bill;
  23.     protected $total_weekly_hrs;
  24.     protected $total_ot_hrs;
  25.     protected $week_start;
  26.     public $wp_system_id;
  27.   //  protected $con;
  28.  
  29.  
  30.     public function __construct($con, $wp_system_id)
  31.     {
  32.         //$this->con = $con;
  33.          $this->wp_system_id = $wp_system_id;
  34.         $this->queryHelper = new QueryHelper($con);
  35.         echo " <br>I just buildt a Queryhelper instance ...";
  36.     }
  37.  
  38.  
  39.     protected abstract function getQueryText();
  40.  
  41.     protected abstract function runQuery();
  42.     
  43.     public function setTimeRows($timerows)
  44.     {
  45.         $this->timerows = $timerows;
  46.     }
  47.  
  48.     public function getTimeRows()
  49.     {
  50.         return $this->timerows;
  51.     }
  52.  
  53.     
  54. }
  55. class QueryHelper {
  56.     
  57.     public function __construct($parm) {
  58.         echo "<br> I am INSIDE a queryhelper thing ... and parm=" . $parm;
  59.     }
  60. }
  61. class TimeEntryCreator extends TimeEntryAbstract
  62. {
  63.   
  64.     private $errmsg_arr = array();
  65.     public $wp_system_id;
  66.    // public function __construct($con, $wp_system_id=732) {
  67.   //      parent::__construct($con); 
  68.   //      $this->wp_system_id = $wp_system_id;
  69.   //  }
  70.     public function getQueryText() {
  71.  
  72.     }
  73.  
  74.     public function runQuery() {
  75.  
  76.     }
  77.  
  78.     private function getJobData() {
  79.  
  80.     }
  81.  
  82.     private function calcTime() {
  83.         # code...
  84.     }
  85.  
  86.     private function deleteTimeEntries($groupId, $week_start, $orderValues) {
  87.      
  88.     }
  89.  
  90. }
  91. $orderDays= array(
  92.     array(8642,
  93.     array(
  94.     1, 
  95.     1, 
  96.     3,
  97.     4)),
  98.     array(8651,
  99.     array(
  100.     0, 
  101.     2, 
  102.     3,
  103.     4)), 
  104.     array(8638,
  105.     array(
  106.     1, 
  107.     3, 
  108.     4,
  109.     5))
  110. );
  111. $tstarr = [];
  112. $con = "Here is the param to the abstract contsrtuctor .... ";
  113. $tst= new TimeEntryCreator($con, 665); //override the wp_system_id value
  114. echo " System id=" . $tst->wp_system_id;
  115. $tst->setTimeRows($orderDays);
  116. $tstarr = $tst->getTimeRows();
  117. foreach($tstarr AS $ord) {
  118.     echo " Order=" . $ord[0];
  119. }
  120.  
  121.  
File Description
  • Constructor testing - using parent or not
  • PHP Code
  • 01 Feb-2021
  • 2.42 Kb
You can Share it: