Ejemplo n.º 1
0
 /**
  * Retrieve a list of the available locations within Reseller Central.
  */
 function get()
 {
     $locations = $this->resellercentralQuery('getLocations');
     if ($locations['success'] != 'true') {
         die('No result');
     }
     $p = new TablePrinter(['ID', 'Location', 'Priority']);
     foreach ($locations['sql'] as $loc) {
         $p->addRow($loc['location_id'], $loc['location'], $loc['priority']);
     }
     $p->output();
 }
Ejemplo n.º 2
0
 /**
  * Retrieve a list of the available locations within Reseller Central.
  */
 function get($account)
 {
     $apiKey = $this->getApiKey($account);
     $params = array('api_key' => $apiKey);
     $packages = $this->resellercentralQuery('getPackages', $params);
     if ($packages['success'] != 'true') {
         die('No result');
     }
     $p = new TablePrinter(['ID', 'Name', 'Quota', 'bandwidth', 'quotausage', 'bwusage', 'accounts']);
     foreach ($packages['sql'] as $pack) {
         $p->addRow($pack['pack_id'], $pack['name'], $pack['quota'], $pack['bandwidth'], $pack['quotausage'], $pack['bwusage'], $pack['accounts']);
     }
     $p->output();
 }
 function printResult($data, $result, $type)
 {
     $p = new TablePrinter(['No.', 'Merchant', 'Product Number']);
     $i = 1;
     foreach ($data['merchantProductNumber'] as $merchant => $number) {
         $p->addRow($i, $merchant, $number);
         $i++;
     }
     $p->output();
     echo "\n";
     echo 'Total Products: ' . $data['totalProducts'];
     echo "\n";
     if ('byProducts' == $type) {
         echo 'Domain Number: ' . $result;
     }
     if ('byDomains' == $type) {
         echo 'Product Number Per Domain: ' . $result;
     }
 }
Ejemplo n.º 4
0
    public function doSomething()
    {
        return 'Something';
    }
    public function aGenericMethod()
    {
        return 9000;
    }
    public function mixItUp()
    {
        return parent::aGenericMethod() . ' ' . parent::doSomething() . ' ' . $this->doSomething();
    }
}
$a = new A();
$b = new B();
$c = new C();
$p = new TablePrinter(['Method', 'Result']);
$p->addRow("A::aGenericMethod()", $a->aGenericMethod());
$p->addRow("B::aGenericMethod()", $b->aGenericMethod());
$p->addRow("C::aGenericMethod()", $c->aGenericMethod());
$p->addRow("B::doSomething()", $b->doSomething());
$p->addRow("C::doSomething()", $c->doSomething());
$p->addRow("C::mixItUp()", $c->mixItUp());
$p->output();
echo "\n\n";
$p = new TablePrinter(['Class', 'setting', 'anotherSetting']);
$p->addRow("A", print_r($a->setting, true), print_r($a->anotherSetting, true));
$p->addRow("B", print_r($b->setting, true), print_r($b->anotherSetting, true));
$p->addRow("C", print_r($c->setting, true), print_r($c->anotherSetting, true));
$p->output();
Ejemplo n.º 5
0
<?php

require '../TablePrinter.php';
function fetchStrategy($type)
{
    $strategies = ['addition' => function ($v1, $v2) {
        return $v1 + $v2;
    }, 'multiplication' => function ($v1, $v2) {
        return $v1 * $v2;
    }];
    return $strategies[$type];
}
function solveMath($type, $v1, $v2)
{
    $strategy = fetchStrategy($type);
    return $strategy($v1, $v2);
}
$tp = new TablePrinter(['Type', 'Result']);
$tp->addRow('Addition', solveMath('addition', 5, 5));
$tp->addRow('Multiplication', solveMath('multiplication', 5, 5));
echo $tp->output();
Ejemplo n.º 6
0
 function displayResults($accounts)
 {
     $i = 1;
     $p = new TablePrinter(['Number', 'Domain', 'User', 'IP Address', 'Location', 'Quota', 'Bandwidth', 'Total Quota', 'Total BW', 'Status']);
     foreach ($accounts as $acc) {
         $p->addRow($i, $acc['domain'], $acc['username'], $acc['ip'], $acc['location'], $acc['rquota'], $acc['rbandwidth'], $acc['rtotal_disk'], $acc['rtotal_bw'], $acc['status']);
         $i++;
     }
     $p->output();
 }
Ejemplo n.º 7
0
<?php

require '../TablePrinter.php';
require 'Loggr.php';
require 'Loggr/EchoOut.php';
require 'Product.php';
require 'PurchaseManager.php';
require 'IoC.php';
IoC::register('Logger', function () {
    return new Loggr(new Loggr\EchoOut());
});
IoC::register('Product', function ($name, $price) {
    return new Product($name, $price);
});
$pm = new PurchaseManager();
$store = [new Product('Juice', '1.99'), new Product('Milk', '3.99'), new Product('Water', '0.99')];
$pm->purchase($store[0]);
$pm->purchase($store[1]);
$pm->purchaseDiscountedProduct($store[2], 50);
$tp = new TablePrinter(['Product', 'Price']);
echo "You've purchased:\n";
foreach ($pm->purchaseHistory() as $purchase) {
    $tp->addRow($purchase->getName(), '$' . $purchase->getPrice());
}
$tp->output();