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.
Result of php executing
Full code of Constructor testing - using parent or not.php
- <?php
- abstract class TimeEntryAbstract
- {
- protected $queryHelper;
- protected $errflag;
- protected $resultMsg;
- protected $orderId;
- protected $groupId;
- protected $dbInsert;
- protected $dbValues;
- protected $orderValues;
- protected $candidate_id;
- protected $bidAmt;
- protected $otRate;
- protected $holidayRate;
- protected $contract_fee; //change to $contractFee when you get all the references in place
- protected $total_weekly_bill; //change
- protected $wp_fee; //change
- protected $reg_hrs;
- protected $ot_hrs;
- protected $line_bill;
- protected $total_weekly_hrs;
- protected $total_ot_hrs;
- protected $week_start;
- public $wp_system_id;
- // protected $con;
- public function __construct($con, $wp_system_id)
- {
- //$this->con = $con;
- $this->wp_system_id = $wp_system_id;
- $this->queryHelper = new QueryHelper($con);
- echo " <br>I just buildt a Queryhelper instance ...";
- }
- protected abstract function getQueryText();
- protected abstract function runQuery();
- public function setTimeRows($timerows)
- {
- $this->timerows = $timerows;
- }
- public function getTimeRows()
- {
- return $this->timerows;
- }
- }
- class QueryHelper {
- public function __construct($parm) {
- echo "<br> I am INSIDE a queryhelper thing ... and parm=" . $parm;
- }
- }
- class TimeEntryCreator extends TimeEntryAbstract
- {
- private $errmsg_arr = array();
- public $wp_system_id;
- // public function __construct($con, $wp_system_id=732) {
- // parent::__construct($con);
- // $this->wp_system_id = $wp_system_id;
- // }
- public function getQueryText() {
- }
- public function runQuery() {
- }
- private function getJobData() {
- }
- private function calcTime() {
- # code...
- }
- private function deleteTimeEntries($groupId, $week_start, $orderValues) {
- }
- }
- $orderDays= array(
- array(8642,
- array(
- 1,
- 1,
- 3,
- 4)),
- array(8651,
- array(
- 0,
- 2,
- 3,
- 4)),
- array(8638,
- array(
- 1,
- 3,
- 4,
- 5))
- );
- $tstarr = [];
- $con = "Here is the param to the abstract contsrtuctor .... ";
- $tst= new TimeEntryCreator($con, 665); //override the wp_system_id value
- echo " System id=" . $tst->wp_system_id;
- $tst->setTimeRows($orderDays);
- $tstarr = $tst->getTimeRows();
- foreach($tstarr AS $ord) {
- echo " Order=" . $ord[0];
- }
File Description
- Constructor testing - using parent or not
- PHP Code
- 01 Feb-2021
- 2.42 Kb
You can Share it:
Latest PHP Pastes