| Conditions | 8 | 
| Paths | 28 | 
| Total Lines | 107 | 
| Code Lines | 75 | 
| Lines | 0 | 
| Ratio | 0 % | 
| Changes | 5 | ||
| Bugs | 1 | 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  | 
            ||
| 20 | public function translationTestDataProvider()  | 
            ||
| 21 |     { | 
            ||
| 22 | $keywords = $this->getKeywords();  | 
            ||
| 23 | $lexer = new Lexer($keywords);  | 
            ||
| 24 | $parser = new Parser($lexer);  | 
            ||
| 25 | $dumper = new KeywordsDumper($keywords);  | 
            ||
| 26 | $keywordsArray = $this->getKeywordsArray();  | 
            ||
| 27 | |||
| 28 | // Remove languages with repeated keywords  | 
            ||
| 29 | unset($keywordsArray['en-old'], $keywordsArray['uz']);  | 
            ||
| 30 | |||
| 31 | $data = array();  | 
            ||
| 32 |         foreach ($keywordsArray as $lang => $i18nKeywords) { | 
            ||
| 33 | $features = array();  | 
            ||
| 34 |             foreach (explode('|', $i18nKeywords['feature']) as $transNum => $featureKeyword) { | 
            ||
| 35 | $line = 1;  | 
            ||
| 36 |                 if ('en' !== $lang) { | 
            ||
| 37 | $line = 2;  | 
            ||
| 38 | }  | 
            ||
| 39 | |||
| 40 | $featureLine = $line;  | 
            ||
| 41 | $line += 5;  | 
            ||
| 42 | |||
| 43 |                 $keywords = explode('|', $i18nKeywords['background']); | 
            ||
| 44 | $backgroundLine = $line;  | 
            ||
| 45 | $line += 1;  | 
            ||
| 46 | $background = new BackgroundNode(null, array_merge(  | 
            ||
| 47 | $this->getSteps($i18nKeywords['given'], 'there is agent A', $line, 'Given'),  | 
            ||
| 48 | $this->getSteps($i18nKeywords['and'], 'there is agent B', $line, 'Given')  | 
            ||
| 49 | ), $keywords[0], $backgroundLine);  | 
            ||
| 50 | |||
| 51 | $line += 1;  | 
            ||
| 52 | |||
| 53 | $scenarios = array();  | 
            ||
| 54 | |||
| 55 |                 foreach (explode('|', $i18nKeywords['scenario']) as $scenarioKeyword) { | 
            ||
| 56 | $scenarioLine = $line;  | 
            ||
| 57 | $line += 1;  | 
            ||
| 58 | |||
| 59 | $steps = array_merge(  | 
            ||
| 60 | $this->getSteps($i18nKeywords['given'], 'there is agent J', $line, 'Given'),  | 
            ||
| 61 | $this->getSteps($i18nKeywords['and'], 'there is agent K', $line, 'Given'),  | 
            ||
| 62 | $this->getSteps($i18nKeywords['when'], 'I erase agent K\'s memory', $line, 'When'),  | 
            ||
| 63 | $this->getSteps($i18nKeywords['then'], 'there should be agent J', $line, 'Then'),  | 
            ||
| 64 | $this->getSteps($i18nKeywords['but'], 'there should not be agent K', $line, 'Then')  | 
            ||
| 65 | );  | 
            ||
| 66 | |||
| 67 |                     $scenarios[] = new ScenarioNode('Erasing agent memory', array(), $steps, $scenarioKeyword, $scenarioLine); | 
            ||
| 68 | $line += 1;  | 
            ||
| 69 | }  | 
            ||
| 70 |                 foreach (explode('|', $i18nKeywords['scenario_outline']) as $outlineKeyword) { | 
            ||
| 71 | $outlineLine = $line;  | 
            ||
| 72 | $line += 1;  | 
            ||
| 73 | |||
| 74 | $steps = array_merge(  | 
            ||
| 75 | $this->getSteps($i18nKeywords['given'], 'there is agent <agent1>', $line, 'Given'),  | 
            ||
| 76 | $this->getSteps($i18nKeywords['and'], 'there is agent <agent2>', $line, 'Given'),  | 
            ||
| 77 | $this->getSteps($i18nKeywords['when'], 'I erase agent <agent2>\'s memory', $line, 'When'),  | 
            ||
| 78 | $this->getSteps($i18nKeywords['then'], 'there should be agent <agent1>', $line, 'Then'),  | 
            ||
| 79 | $this->getSteps($i18nKeywords['but'], 'there should not be agent <agent2>', $line, 'Then')  | 
            ||
| 80 | );  | 
            ||
| 81 | $line += 1;  | 
            ||
| 82 | |||
| 83 |                     $keywords = explode('|', $i18nKeywords['examples']); | 
            ||
| 84 | $table = new ExampleTableNode(array(  | 
            ||
| 85 |                         ++$line => array('agent1', 'agent2'), | 
            ||
| 86 |                         ++$line => array('D', 'M') | 
            ||
| 87 | ), $keywords[0]);  | 
            ||
| 88 | $line += 1;  | 
            ||
| 89 | |||
| 90 |                     $scenarios[] = new OutlineNode('Erasing other agents\' memory', array(), $steps, $table, $outlineKeyword, $outlineLine); | 
            ||
| 91 | $line += 1;  | 
            ||
| 92 | }  | 
            ||
| 93 | |||
| 94 | $features[] = new FeatureNode(  | 
            ||
| 95 | 'Internal operations',  | 
            ||
| 96 | <<<DESC  | 
            ||
| 97 | In order to stay secret  | 
            ||
| 98 | As a secret organization  | 
            ||
| 99 | We need to be able to erase past agents' memory  | 
            ||
| 100 | DESC  | 
            ||
| 101 | ,  | 
            ||
| 
                                                                                                    
                        
                         | 
                |||
| 102 | array(),  | 
            ||
| 103 | $background,  | 
            ||
| 104 | $scenarios,  | 
            ||
| 105 | $featureKeyword,  | 
            ||
| 106 | $lang,  | 
            ||
| 107 | $lang . '_' . ($transNum + 1) . '.feature',  | 
            ||
| 108 | $featureLine  | 
            ||
| 109 | );  | 
            ||
| 110 | }  | 
            ||
| 111 | |||
| 112 | $dumped = $dumper->dump($lang, false, true);  | 
            ||
| 113 | $parsed = array();  | 
            ||
| 114 |             try { | 
            ||
| 115 |                 foreach ($dumped as $num => $dumpedFeature) { | 
            ||
| 116 | $parsed[] = $parser->parse($dumpedFeature, $lang . '_' . ($num + 1) . '.feature');  | 
            ||
| 117 | }  | 
            ||
| 118 |             } catch (\Exception $e) { | 
            ||
| 119 | throw new \Exception($e->getMessage() . ":\n" . json_encode($dumped), 0, $e);  | 
            ||
| 120 | }  | 
            ||
| 121 | |||
| 122 | $data[] = array($lang, $features, $parsed);  | 
            ||
| 123 | }  | 
            ||
| 124 | |||
| 125 | return $data;  | 
            ||
| 126 | }  | 
            ||
| 127 | |||
| 140 |