PHP Classes
elePHPant
Icontem

File: Falcraft/examples/Data/Types/Priority.php

Recommend this page to a friend!
  Classes of Asher Wolfstein  >  Abstract Data Types  >  Falcraft/examples/Data/Types/Priority.php  >  Download  
File: Falcraft/examples/Data/Types/Priority.php
Role: Example script
Content type: text/plain
Description: Priority (For PriorityQueue) Example
Class: Abstract Data Types
Set of abstract data types as pure PHP classes
Author: By
Last change:
Date: 3 years ago
Size: 1,384 bytes
 

 

Contents

Class file image Download
<?php

require_once('../../../Data/Types/Priority.php');

use
Falcraft\Data\Types;

echo
"Falcraft\\Data\\Types\\Priority.php Test\n";
echo
"-------------------------------------\n\n";

echo
"Instantiation -> ";

$success = true;

$testPriority = null;

try {
   
$testPriority = new Types\Priority('data');
} catch (\
Exception $e) {
   
$success = false;
}

if (
$success) {
    echo
"Success!\n\n";
    echo
"Priority Internals -- \n\n";
   
var_dump($testPriority);
    echo
"\n";
} else {
    echo
"Failure...\n";
}

echo
"Using Priority Object With Object as Data -> ";

class
testClass {
    public
$publicProp;
}

$success = true;

$testPriority = $obj = $r = null;

try {
   
$obj = new testClass();
   
$obj->publicProp = 'data';
   
$testPriority = new Types\Priority($obj);
   
$r = $testPriority->getData();
} catch (\
Exception $e) {
   
$success = false;
}

if (
$success) {
    echo
"Success!\n\n";
    echo
"Priority Internals -- \n\n";
   
var_dump($testPriority);
    echo
"\n";
   
var_dump($r);
    echo
"\n";
} else {
    echo
"Failure...\n";
}

echo
"Testing Priority Property -> ";

$success = true;

$testPriority = $p = null;

try {
   
$testPriority = new Types\Priority('data', 5);
   
$p = $testPriority->getPriority();
} catch (\
Exception $e) {
   
$success = false;
}

if (
$success) {
    echo
"Success! Priority: $p\n";
} else {
    echo
"Failure...\n";
}