« Back to the index
\core\WADebug example
";
echo "DomCore version ".\core\WADebug::VERSION."
";
echo "HTML API ? ".(\core\WADebug::getHTMLAPI()?'Yes':'No')."
";
echo "OS Type ? ".(\core\WADebug::getOSType()==\core\WADebug::WINDOWS?'Windows':(\core\WADebug::getOSType()==\core\WADebug::UNIX?'Unix':'Mac'))."
";
echo "
";
class vehicle extends \core\WADebug
{
protected $speed;
public function __construct($speed)
{
parent::__construct();
$this->speed = $speed;
}
}
class car extends vehicle
{
public $color;
private $brand;
public function __construct($brand, $color)
{
parent::__construct(200);
$this->brand = $brand;
$this->color = $color;
}
public function setColor($color)
{
// We could call directly the doDebug method, but making the test here, it's extremely faster for the interpreter
if (self::$debug || $this->localdebug)
$this->doDebug("Method call: car->setColor( % )", \core\WADebug::USER, $color);
$this->color = $color;
}
public function getColor()
{
// We could call directly the doDebug method, but making the test here, it's extremely faster for the interpreter
if (self::$debug || $this->localdebug)
$this->doDebug("Method call: car->getColor()", \core\WADebug::USER);
return $this->color;
}
}
$mycar = new car('Ford Fiesta', 'red');
// We show all the properties of mycar
// check that the total quantity of instances is 1 since we only created one up to now
echo "Show the instance mycar:
";
echo $mycar->explain();
echo "
";
class plane extends vehicle
{
public $number_of_motors;
protected $color;
public function __construct($number_of_motors)
{
parent::__construct(1500);
$this->number_of_motors = $number_of_motors;
}
public function setColor($color)
{
// We could call directly the doDebug method, but making the test here, it's extremely faster for the interpreter
if (self::$debug || $this->localdebug)
$this->doDebug("Method call: plane->setColor( % )", \core\WADebug::USER, $color);
$this->color = $color;
}
public function getColor()
{
// We could call directly the doDebug method, but making the test here, it's extremely faster for the interpreter
if (self::$debug || $this->localdebug)
$this->doDebug("Method call: plane->getColor()", \core\WADebug::USER);
return $this->color;
}
}
$myplane = new plane(4);
// We show all the properties of myplane
// check that the total quantity of instances is now 2 since we only created another one up to now
echo "Show the instance mycar again:
";
echo $mycar->explain();
echo "
";
echo "Show the instance myplane:
";
echo $myplane->explain();
echo "
";
echo "Let's paint our properties in blue:
";
$mycar->setColor('blue');
$myplane->setColor('blue');
echo "My car is ".$mycar->getColor()."
";
echo "My plane is ".$myplane->getColor()."
";
echo "
";
// We switch to local debug mode
echo "Let's switch car local debug On:
";
$mycar->setLocalDebug(true);
echo "Let's paint our properties in green:
";
$mycar->setColor('green');
$myplane->setColor('green');
echo "My car is ".$mycar->getColor()."
";
echo "My plane is ".$myplane->getColor()."
";
echo "
";
// We switch to full debug
echo "Let's switch global debug On:
";
\core\WADebug::setDebug(true);
echo "Let's paint our properties again:
";
$mycar->setColor('orange');
$myplane->setColor('black');
echo "My car is ".$mycar->getColor()."
";
echo "My plane is ".$myplane->getColor()."
";
echo "
";
echo "Show the instance mycar again:
";
echo $mycar->explain();
echo "
";
echo "Show the instance myplane again:
";
echo $myplane->explain();
echo "
";
?>
« Back to the index