| Conditions | 2 | 
| Paths | 2 | 
| Total Lines | 79 | 
| Code Lines | 60 | 
| Lines | 0 | 
| Ratio | 0 % | 
| Changes | 0 | ||
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  | 
            ||
| 11 | 	public function forDNDeployment(\DNDeployment $obj) { | 
            ||
| 12 | $loader = new Finite\Loader\ArrayLoader([  | 
            ||
| 13 | 'class' => 'DNDeployment',  | 
            ||
| 14 | 'states' => [  | 
            ||
| 15 | DNDeployment::STATE_NEW => ['type' => StateInterface::TYPE_INITIAL],  | 
            ||
| 16 | DNDeployment::STATE_SUBMITTED => ['type' => StateInterface::TYPE_NORMAL],  | 
            ||
| 17 | DNDeployment::STATE_INVALID => ['type' => StateInterface::TYPE_NORMAL],  | 
            ||
| 18 | DNDeployment::STATE_APPROVED => ['type' => StateInterface::TYPE_NORMAL],  | 
            ||
| 19 | DNDeployment::STATE_REJECTED => ['type' => StateInterface::TYPE_NORMAL],  | 
            ||
| 20 | DNDeployment::STATE_QUEUED => ['type' => StateInterface::TYPE_NORMAL],  | 
            ||
| 21 | DNDeployment::STATE_DEPLOYING => ['type' => StateInterface::TYPE_NORMAL],  | 
            ||
| 22 | DNDeployment::STATE_ABORTING => ['type' => StateInterface::TYPE_NORMAL],  | 
            ||
| 23 | DNDeployment::STATE_COMPLETED => ['type' => StateInterface::TYPE_FINAL],  | 
            ||
| 24 | DNDeployment::STATE_FAILED => ['type' => StateInterface::TYPE_FINAL],  | 
            ||
| 25 | ],  | 
            ||
| 26 | 'transitions' => [  | 
            ||
| 27 | DNDeployment::TR_NEW => ['from' => [DNDeployment::STATE_SUBMITTED], 'to' => DNDeployment::STATE_NEW],  | 
            ||
| 28 | DNDeployment::TR_SUBMIT => ['from' => [DNDeployment::STATE_NEW], 'to' => DNDeployment::STATE_SUBMITTED],  | 
            ||
| 29 | DNDeployment::TR_QUEUE => [  | 
            ||
| 30 | 'from' => [  | 
            ||
| 31 | DNDeployment::STATE_NEW, // @deprecated. Remove this when DNRoot::startDeploy() is removed.  | 
            ||
| 32 | DNDeployment::STATE_APPROVED  | 
            ||
| 33 | ],  | 
            ||
| 34 | 'to' => DNDeployment::STATE_QUEUED  | 
            ||
| 35 | ],  | 
            ||
| 36 | DNDeployment::TR_INVALIDATE => [  | 
            ||
| 37 | 'from' => [  | 
            ||
| 38 | DNDeployment::STATE_NEW,  | 
            ||
| 39 | DNDeployment::STATE_SUBMITTED,  | 
            ||
| 40 | DNDeployment::STATE_APPROVED,  | 
            ||
| 41 | DNDeployment::STATE_REJECTED  | 
            ||
| 42 | ],  | 
            ||
| 43 | 'to' => DNDeployment::STATE_INVALID  | 
            ||
| 44 | ],  | 
            ||
| 45 | DNDeployment::TR_APPROVE => ['from' => [  | 
            ||
| 46 | DNDeployment::STATE_NEW,  | 
            ||
| 47 | DNDeployment::STATE_SUBMITTED  | 
            ||
| 48 | ],  | 
            ||
| 49 | 'to' => DNDeployment::STATE_APPROVED  | 
            ||
| 50 | ],  | 
            ||
| 51 | DNDeployment::TR_REJECT => ['from' => [DNDeployment::STATE_SUBMITTED], 'to' => DNDeployment::STATE_REJECTED],  | 
            ||
| 52 | DNDeployment::TR_DEPLOY => ['from' => [DNDeployment::STATE_QUEUED], 'to' => DNDeployment::STATE_DEPLOYING],  | 
            ||
| 53 | DNDeployment::TR_ABORT => [  | 
            ||
| 54 | 'from' => [  | 
            ||
| 55 | DNDeployment::STATE_QUEUED,  | 
            ||
| 56 | DNDeployment::STATE_DEPLOYING,  | 
            ||
| 57 | DNDeployment::STATE_ABORTING  | 
            ||
| 58 | ],  | 
            ||
| 59 | 'to' => DNDeployment::STATE_ABORTING  | 
            ||
| 60 | ],  | 
            ||
| 61 | DNDeployment::TR_COMPLETE => ['from' => [DNDeployment::STATE_DEPLOYING], 'to' => DNDeployment::STATE_COMPLETED],  | 
            ||
| 62 | DNDeployment::TR_FAIL => [  | 
            ||
| 63 | 'from' => [  | 
            ||
| 64 | DNDeployment::STATE_NEW,  | 
            ||
| 65 | DNDeployment::STATE_SUBMITTED,  | 
            ||
| 66 | DNDeployment::STATE_INVALID,  | 
            ||
| 67 | DNDeployment::STATE_REJECTED,  | 
            ||
| 68 | DNDeployment::STATE_APPROVED,  | 
            ||
| 69 | DNDeployment::STATE_QUEUED,  | 
            ||
| 70 | DNDeployment::STATE_DEPLOYING,  | 
            ||
| 71 | DNDeployment::STATE_ABORTING  | 
            ||
| 72 | ],  | 
            ||
| 73 | 'to' => DNDeployment::STATE_FAILED  | 
            ||
| 74 | ],  | 
            ||
| 75 | ]  | 
            ||
| 76 | ]);  | 
            ||
| 77 | 		$stateMachine = Injector::inst()->get('Finite\StateMachine\StateMachine', true, [$obj]); | 
            ||
| 78 | |||
| 79 | // if we have already initialised a state machine for the given \DNDeployment  | 
            ||
| 80 | // then don't re-initialise it again, as this causes bugs with transition events  | 
            ||
| 81 | // being called multiple times.  | 
            ||
| 82 | 		if (empty(self::$initialised[$obj->ID])) { | 
            ||
| 83 | $loader->load($stateMachine);  | 
            ||
| 84 | $stateMachine->initialize();  | 
            ||
| 85 | $this->addHandlers($stateMachine);  | 
            ||
| 86 | self::$initialised[$obj->ID] = true;  | 
            ||
| 87 | }  | 
            ||
| 88 | return $stateMachine;  | 
            ||
| 89 | }  | 
            ||
| 90 | |||
| 121 | 
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.