| Conditions | 10 | 
| Paths | 62 | 
| Total Lines | 69 | 
| 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  | 
            ||
| 91 | protected function process()  | 
            ||
| 92 |     { | 
            ||
| 93 | |||
| 94 | // initialize the URL key and array for the categories  | 
            ||
| 95 | $urlKey = null;  | 
            ||
| 
                                                                                                    
                        
                         | 
                |||
| 96 | $category = array();  | 
            ||
| 97 | |||
| 98 | // set the entity ID for the category with the passed path  | 
            ||
| 99 |         try { | 
            ||
| 100 | $this->setIds($category = $this->getCategoryByPath($this->getValue(ColumnKeys::PATH)));  | 
            ||
| 101 |         } catch (\Exception $e) { | 
            ||
| 102 | $this->setIds(array());  | 
            ||
| 103 | }  | 
            ||
| 104 | |||
| 105 | // query whether or not the URL key column has a value  | 
            ||
| 106 |         if ($this->hasValue(ColumnKeys::URL_KEY)) { | 
            ||
| 107 | $urlKey = $this->makeUnique($this->getSubject(), $this->getValue(ColumnKeys::URL_KEY));  | 
            ||
| 108 |         } else { | 
            ||
| 109 | // query whether or not the column `url_key` has a value  | 
            ||
| 110 | if ($category &&  | 
            ||
| 111 | !$this->getSubject()->getConfiguration()->getParam(ConfigurationKeys::UPDATE_URL_KEY_FROM_NAME, true)  | 
            ||
| 112 |             ) { | 
            ||
| 113 | // product already exists and NO new URL key  | 
            ||
| 114 | // has been specified in column `url_key`, so  | 
            ||
| 115 | // we stop processing here  | 
            ||
| 116 | return;  | 
            ||
| 117 | }  | 
            ||
| 118 | $this->setValue(  | 
            ||
| 119 | ColumnKeys::URL_KEY,  | 
            ||
| 120 | $urlKey = $this->makeUnique($this->getSubject(), $this->convertNameToUrlKey($this->getValue(ColumnKeys::NAME)))  | 
            ||
| 121 | );  | 
            ||
| 122 | }  | 
            ||
| 123 | |||
| 124 | // explode the path into the category names  | 
            ||
| 125 |         if ($categories = $this->explode($this->getValue(ColumnKeys::PATH), '/')) { | 
            ||
| 126 | // initialize the category with the actual category's URL key  | 
            ||
| 127 | $categoryPaths = array($urlKey);  | 
            ||
| 128 | // prepare the store view code  | 
            ||
| 129 | $this->prepareStoreViewCode();  | 
            ||
| 130 | // load ID of the actual store view  | 
            ||
| 131 | $storeId = $this->getRowStoreId(StoreViewCodes::ADMIN);  | 
            ||
| 132 | |||
| 133 | // iterate over the category names and try to load the category therefore  | 
            ||
| 134 |             for ($i = sizeof($categories) - 1; $i > 1; $i--) { | 
            ||
| 135 |                 try { | 
            ||
| 136 | // prepare the expected category name  | 
            ||
| 137 |                     $categoryPath = implode('/', array_slice($categories, 0, $i)); | 
            ||
| 138 | // load the existing category and prepend the URL key the array with the category URL keys  | 
            ||
| 139 | $existingCategory = $this->getCategoryByPkAndStoreId($this->mapPath($categoryPath), $storeId);  | 
            ||
| 140 | // query whether or not an URL key is available or not  | 
            ||
| 141 |                     if (isset($existingCategory[MemberNames::URL_KEY])) { | 
            ||
| 142 | array_unshift($categoryPaths, $existingCategory[MemberNames::URL_KEY]);  | 
            ||
| 143 |                     } else { | 
            ||
| 144 |                         $this->getSystemLogger()->debug(sprintf('Can\'t find URL key for category %s', $categoryPath)); | 
            ||
| 145 | }  | 
            ||
| 146 |                 } catch (\Exception $e) { | 
            ||
| 147 |                     $this->getSystemLogger()->debug(sprintf('Can\'t load parent category %s', $categoryPath)); | 
            ||
| 148 | }  | 
            ||
| 149 | }  | 
            ||
| 150 | |||
| 151 | // create the header for the URL path  | 
            ||
| 152 |             if (!$this->hasHeader(ColumnKeys::URL_PATH)) { | 
            ||
| 153 | $this->addHeader(ColumnKeys::URL_PATH);  | 
            ||
| 154 | }  | 
            ||
| 155 | |||
| 156 | // set the URL path  | 
            ||
| 157 |             $this->setValue(ColumnKeys::URL_PATH, implode('/', $categoryPaths)); | 
            ||
| 158 | }  | 
            ||
| 159 | }  | 
            ||
| 160 | |||
| 254 | 
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVarassignment in line 1 and the$higherassignment in line 2 are dead. The first because$myVaris never used and the second because$higheris always overwritten for every possible time line.