Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class Base
- {
- protected $_availableSizes = array();
- public function __call($name, $args)
- {
- $action = strtolower(substr($name, 0, 3));
- $field = '_' . strtolower($name[3]) . substr($name, 4);
- switch ($action) {
- case 'set':
- $this->$field = $args[0];
- break;
- case 'get':
- return $this->$field;
- break;
- default:
- break;
- }
- }
- }
- class Foo extends Base
- {
- /**
- * Overrides the admin setAvailableSizes to ensure every
- * item within the context of an Order has a size and cost.
- *
- * @return void
- **/
- public function setAvailableSizes(array $sizes)
- {
- parent::setAvailableSizes($sizes);
- if (empty($this->_availableSizes)) {
- $this->_availableSizes[] = array(
- 'name' => 'Default',
- 'cost' => 0.00,
- );
- }
- }
- }
- $foo = new Foo();
- $foo->setAvailableSizes(array(
- array(
- 'name' => 'Test',
- 'cost' => '0.00',
- ),
- ));
- var_dump($foo);
Add Comment
Please, Sign In to add comment