| Conditions | 11 | 
| Paths | 24 | 
| Total Lines | 48 | 
| Code Lines | 23 | 
| 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 declare(strict_types=1);  | 
            ||
| 32 | public function extract(Context $context, Value $value, PlainExtractorDefinitionInterface $definition, ExtractorInterface $extractor)  | 
            ||
| 33 |     { | 
            ||
| 34 |         if ($value instanceof RegExpObject) { | 
            ||
| 35 | |||
| 36 | $regex = $value->getSource()->value();  | 
            ||
| 37 | |||
| 38 |             if ($definition->getNext() && 'string' == $definition->getNext()->getName()) { | 
            ||
| 39 | return $regex;  | 
            ||
| 40 | }  | 
            ||
| 41 | |||
| 42 | $flags = $value->getFlags();  | 
            ||
| 43 | $regexp = '/' . preg_quote($regex, '/') . '/';  | 
            ||
| 44 | |||
| 45 |             if (!$flags) { | 
            ||
| 46 | return $regexp;  | 
            ||
| 47 | }  | 
            ||
| 48 | |||
| 49 |             if ($flags & RegExpObject::FLAG_GLOBAL) { | 
            ||
| 50 | // global flag is not supported in PHP  | 
            ||
| 51 |                 throw new ExtractorException('Global flag is not supported'); | 
            ||
| 52 | }  | 
            ||
| 53 | |||
| 54 |             if ($flags & RegExpObject::FLAG_IGNORE_CASE) { | 
            ||
| 55 | $regexp .= 'i';  | 
            ||
| 56 | }  | 
            ||
| 57 | |||
| 58 |             if ($flags & RegExpObject::FLAG_MULTILINE) { | 
            ||
| 59 | $regexp .= 'm';  | 
            ||
| 60 | }  | 
            ||
| 61 | |||
| 62 |             if ($flags & RegExpObject::FLAG_STICKY) { | 
            ||
| 63 | // sticky flag is not supported in PHP  | 
            ||
| 64 |                 throw new ExtractorException('Sticky flag is not supported'); | 
            ||
| 65 | }  | 
            ||
| 66 | |||
| 67 |             if ($flags & RegExpObject::FLAG_UNICODE) { | 
            ||
| 68 | $regexp .= 'u';  | 
            ||
| 69 | }  | 
            ||
| 70 | |||
| 71 |             if ($flags & RegExpObject::FLAG_DOTALL) { | 
            ||
| 72 | $regexp .= 's';  | 
            ||
| 73 | }  | 
            ||
| 74 | |||
| 75 | return $regexp;  | 
            ||
| 76 | }  | 
            ||
| 77 | |||
| 78 |         throw new ExtractorException('Value must be of the type regexp, ' . $value->typeOf()->value() . ' given'); | 
            ||
| 79 | }  | 
            ||
| 80 | }  | 
            ||
| 81 |