| Conditions | 11 | 
| Paths | 18 | 
| Total Lines | 50 | 
| Code Lines | 18 | 
| Lines | 0 | 
| Ratio | 0 % | 
| Changes | 1 | ||
| Bugs | 0 | Features | 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  | 
            ||
| 19 |     protected function tagOpen( $parser, string $name, array $attr ) { | 
            ||
| 20 | |||
| 21 | $this->handleOpenUnit( $name, $attr );  | 
            ||
| 22 | |||
| 23 | // check if we are entering into a <target>  | 
            ||
| 24 | $this->checkSetInTarget( $name );  | 
            ||
| 25 | |||
| 26 | // reset Marker positions  | 
            ||
| 27 |         if ( 'sdl:seg-defs' == $name ) { | 
            ||
| 28 | $this->segmentInUnitPosition = 0;  | 
            ||
| 29 | }  | 
            ||
| 30 | |||
| 31 | // open buffer  | 
            ||
| 32 | $this->setInBuffer( $name );  | 
            ||
| 33 | |||
| 34 | // check if we are inside a <target>, obviously this happen only if there are targets inside the trans-unit  | 
            ||
| 35 | // <target> must be stripped to be replaced, so this check avoids <target> reconstruction  | 
            ||
| 36 |         if ( !$this->inTarget ) { | 
            ||
| 37 | |||
| 38 | // costruct tag  | 
            ||
| 39 | $tag = "<$name ";  | 
            ||
| 40 | |||
| 41 | // needed to avoid multiple conf writing inside the same tag  | 
            ||
| 42 | // because the "conf" attribute could be not present in the tag,  | 
            ||
| 43 | // so the check on it's name is not enough  | 
            ||
| 44 | $_sdlStatus_confWritten = false;  | 
            ||
| 
                                                                                                    
                        
                         | 
                |||
| 45 | |||
| 46 |             foreach ( $attr as $k => $v ) { | 
            ||
| 47 | |||
| 48 | // if tag name is file, we must replace the target-language attribute  | 
            ||
| 49 |                 if ( $name == 'file' && $k == 'target-language' && !empty( $this->targetLang ) ) { | 
            ||
| 50 | //replace Target language with job language provided from constructor  | 
            ||
| 51 | $tag .= "$k=\"$this->targetLang\" ";  | 
            ||
| 52 |                 } else { | 
            ||
| 53 | //normal tag flux, put attributes in it  | 
            ||
| 54 | // Warning, this is NOT an elseif  | 
            ||
| 55 |                     if ( $k != 'conf' ) { | 
            ||
| 56 | //put also the current attribute in it if it is not a "conf" attribute  | 
            ||
| 57 | $tag .= "$k=\"$v\" ";  | 
            ||
| 58 | }  | 
            ||
| 59 | }  | 
            ||
| 60 | }  | 
            ||
| 61 | |||
| 62 | $seg = $this->getCurrentSegment();  | 
            ||
| 63 | |||
| 64 |             if ( 'sdl:seg' == $name && !empty( $seg ) and isset( $seg[ 'sid' ] ) ) { | 
            ||
| 65 | $tag .= $this->prepareTargetStatuses( $seg );  | 
            ||
| 66 | }  | 
            ||
| 67 | |||
| 68 | $this->checkForSelfClosedTagAndFlush( $parser, $tag );  | 
            ||
| 69 | |||
| 108 | }  |