Skip to content

Instantly share code, notes, and snippets.

@ShonM
Created June 25, 2014 21:23
Show Gist options
  • Save ShonM/6585f04127430ea69379 to your computer and use it in GitHub Desktop.
Save ShonM/6585f04127430ea69379 to your computer and use it in GitHub Desktop.
<?php
class Customer {
protected $machine;
public function __construct($machine) {
$this->machine = $machine;
}
public function purchase($shelf) {
return $this->machine->rPop($shelf);
}
}
$machine = new Redis;
$machine->connect('127.0.0.1');
$customer = new Customer($machine);
$pop = $customer->purchase($argv[1]);
echo 'Got a ' . $pop . '!' . PHP_EOL;
<?php
class Employee {
protected $machine;
public function __construct($machine) {
$this->machine = $machine;
}
public function stock($shelf, $pop) {
return $this->machine->lPush($shelf, $pop);
}
}
$machine = new Redis;
$machine->connect('127.0.0.1');
$employee = new Employee($machine);
$pop = $employee->stock($argv[1], $argv[2]);
echo 'Stocked a ' . $argv[1] . ' on the ' . $argv[2] . ' shelf' . PHP_EOL;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment