} function getAncodes() { return $this->ancodes; } function getAncode($ancodeId, $resolve = true) { $ancode_id = $resolve ? $this->resolveAncode($ancodeId) : (int) $ancodeId; return $this->ancodes[$ancode_id]; } protected function createAncode(phpMorphy_Dict_Ancode $ancode) { return new phpMorphy_Dict_Ancode_Normalized($this->registerAncodeId($ancode->getId()), $ancode->getId(), $this->registerPos($ancode->getPartOfSpeech(), $ancode->isPredict()), $this->registerGrammems($ancode->getGrammems()), $ancode->getId()); } } lmbDecorator::generate('phpMorphy_Dict_Source_Interface', 'phpMorphy_Dict_Source_Normalized_Decorator'); class phpMorphy_Dict_Source_Normalized_Ancodes extends phpMorphy_Dict_Source_Normalized_Decorator { protected $manager; static function wrap(phpMorphy_Dict_Source_Interface $source) { $self = __CLASS__; if ($source instanceof $self) { return $source; } return new $self($source); } function __construct(phpMorphy_Dict_Source_Interface $inner) { parent::__construct($inner); $this->manager = $this->createManager($inner);
<?php /* * Limb PHP Framework * * @link http://limb-project.com * @copyright Copyright © 2004-2009 BIT(http://bit-creative.com) * @license LGPL http://www.gnu.org/copyleft/lesser.html */ lmb_require('limb/dbal/src/drivers/lmbDbConnection.interface.php'); lmb_require('limb/core/src/lmbBacktrace.class.php'); lmb_require('limb/core/src/lmbDecorator.class.php'); lmbDecorator::generate('lmbDbConnection', 'lmbDbConnectionDecorator'); /** * class lmbAuditDbConnection. * Remembers stats for later analysis, especially useful in tests * @package dbal * @version $Id$ */ class lmbAuditDbConnection extends lmbDbConnectionDecorator { protected $stats = array(); protected $statement_number = 0; function getStatementNumber() { return ++$this->statement_number; } function execute($sql) { $info = array('query' => $sql); $info['trace'] = $this->getTrace();
function testCallsPassedToDecorated() { $rnd = mt_rand(); $class = 'DecoratorTestStub' . $rnd; $this->assertTrue(lmbDecorator::generate('DecorateeTestStub', $class)); $decorator = new $class(new DecorateeTestStub()); $decorator->set('foo'); $this->assertEqual($decorator->get(), 'foo'); }
<?php /* * Limb PHP Framework * * @link http://limb-project.com * @copyright Copyright © 2004-2009 BIT(http://bit-creative.com) * @license LGPL http://www.gnu.org/copyleft/lesser.html */ /** * @package tree * @version $Id: lmbTreeDecorator.class.php 7486 2009-01-26 19:13:20Z pachanga $ */ lmb_require('limb/tree/src/lmbTree.interface.php'); lmb_require('limb/core/src/lmbDecorator.class.php'); lmbDecorator::generate('lmbTree', 'lmbTreeDecorator');
static function generate($proxy_class, $proxied_class) { return lmbDecorator::generate($proxied_class, $proxy_class, new lmbARProxyGeneratorEventsHandler()); }