| Conditions | 14 |
| Paths | 1536 |
| Total Lines | 55 |
| Code Lines | 38 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 22 | ||
| Bugs | 4 | Features | 1 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php namespace Comodojo\Extender; |
||
| 21 | public function __construct( |
||
| 22 | $configuration = array(), |
||
| 23 | LoggerInterface $logger = null, |
||
| 24 | EventsManager $events = null, |
||
| 25 | Cache $cache = null |
||
| 26 | ) { |
||
| 27 | |||
| 28 | // parsing configuration |
||
| 29 | $this->configuration = new Configuration( DefaultConfiguration::get() ); |
||
|
|
|||
| 30 | $this->configuration->merge($configuration); |
||
| 31 | |||
| 32 | // fix the daemon start time |
||
| 33 | $this->starttime = microtime(true); |
||
| 34 | |||
| 35 | // init counters |
||
| 36 | $this->completedjobs = 0; |
||
| 37 | $this->failedjobs = 0; |
||
| 38 | $this->currentjobs = new Results(); |
||
| 39 | |||
| 40 | // init the console |
||
| 41 | $this->console = new CLImate(); |
||
| 42 | $this->console->description(Version::getFullDescription($this->configuration)); |
||
| 43 | $this->console->arguments->add($this->console_arguments); |
||
| 44 | $this->console->arguments->parse(); |
||
| 45 | |||
| 46 | // init the logger |
||
| 47 | $this->logger = is_null($logger) ? LogManager::create($this->configuration, 'extender') : $logger; |
||
| 48 | if ( $this->console->arguments->get('verbose') === true ) { |
||
| 49 | $this->logger->pushHandler(new LogHandler()); |
||
| 50 | } |
||
| 51 | |||
| 52 | // init event manager |
||
| 53 | $this->events = is_null($events) ? new EventsManager($this->logger) : $events; |
||
| 54 | |||
| 55 | // init the cache abstraction layer |
||
| 56 | $this->cache = is_null($cache) ? CacheManager::create($this->configuration, $this->logger) : $cache; |
||
| 57 | |||
| 58 | // install the loop limiter |
||
| 59 | $this->looplimit = $this->console->arguments->get('iterations'); |
||
| 60 | $this->events->subscribe("extender.daemon.loopstop", "\Comodojo\Extender\Listeners\LoopLimit"); |
||
| 61 | |||
| 62 | // install the summary report listener if requested |
||
| 63 | if ( $this->console->arguments->get('summary') === true ) { |
||
| 64 | $this->events->subscribe("extender.daemon.loopstop", "\Comodojo\Extender\Listeners\LoopSummary"); |
||
| 65 | $this->events->subscribe("extender.daemon.stop", "\Comodojo\Extender\Listeners\StopSummary"); |
||
| 66 | } |
||
| 67 | |||
| 68 | // get daemon parameters |
||
| 69 | $looptime = $this->configuration->get('looptime'); |
||
| 70 | $niceness = $this->configuration->get('niceness'); |
||
| 71 | |||
| 72 | // build daemon |
||
| 73 | parent::__construct($this->configuration, $this->logger, $this->events, $looptime, $niceness); |
||
| 74 | |||
| 75 | } |
||
| 76 | |||
| 113 |
Since your code implements the magic setter
_set, this function will be called for any write access on an undefined variable. You can add the@propertyannotation to your class or interface to document the existence of this variable.Since the property has write access only, you can use the @property-write annotation instead.
Of course, you may also just have mistyped another name, in which case you should fix the error.
See also the PhpDoc documentation for @property.