PEIP_Dedicated_Factory.php

Go to the documentation of this file.
00001 <?php
00002 
00003 /*
00004  * This file is part of the PEIP package.
00005  * (c) 2010 Timo Michna <timomichna/yahoo.de>
00006  * 
00007  * For the full copyright and license information, please view the LICENSE
00008  * file that was distributed with this source code.
00009  */
00010 
00023 class PEIP_Dedicated_Factory 
00024     extends PEIP_Parameter_Holder 
00025     implements PEIP_INF_Dedicated_Factory {
00026 
00027     protected $callable;        
00028     
00029     
00036     protected function __construct($callable ,array $parameters = array()){
00037         $this->callable = $callable;
00038         $this->setParameters($parameters);
00039     }
00040 
00041     public static function getfromClass($class, array $parameters = array()){
00042         return new PEIP_Dedicated_Factory(array($class, '__construct'), $parameters); 
00043     } 
00044 
00045     public static function getfromCallable($callable, array $parameters = array()){
00046         return new PEIP_Dedicated_Factory($callable, $parameters); 
00047     } 
00048     
00049     
00055     public function build(array $arguments = array()){
00056         $arguments = count($arguments) > 0 ? $arguments : $this->getParameters();
00057         return (is_array($this->callable) && $this->callable[1] == '__construct') 
00058             ? PEIP_Generic_Builder::GetInstance($this->callable[0])->build($arguments) 
00059             : call_user_func_array($this->callable, $arguments);
00060     }
00061 
00062     
00068     public function setConstructor($method){
00069         $this->constructor = (string)$method;
00070         return $this;
00071     }   
00072     
00073 }

Generated on Mon Apr 12 11:39:00 2010 for PEIP by  doxygen 1.5.1