protected function findPositionToInsert($lines, $type)
    {
        // Major are always inserted at the top
        if ($type == 'major') {
            return 0;
        }

        // Minor must be inserted one line above the first major section
        if ($type == 'minor') {
            foreach ($lines as $pos => $line) {
                if (preg_match('/^=======/', $line)) {
                    return $pos + 1;
                }
            }
        }

        // Patch should go directly after the first minor
        if ($type == 'patch') {
            foreach ($lines as $pos => $line) {
                if (preg_match('/Version\s\d+\.\d+\s\-/', $line)) {
                    return $pos + 1;
                }
            }
        }

        throw new \Liip\RMT\Exception('Invalid changelog formatting');
    }
protected function findPositionToInsert($lines, $type)
    {
        // Major are always inserted at the top
        if ($type == 'major') {
            return 0;
        }

        // Minor must be inserted one line above the first major section
        if ($type == 'minor') {
            foreach ($lines as $pos => $line) {
                if (preg_match('/^=======/', $line)) {
                    return $pos + 1;
                }
            }
        }

        // Patch should go directly after the first minor
        if ($type == 'patch') {
            foreach ($lines as $pos => $line) {
                if (preg_match('/Version\s\d+\.\d+\s\-/', $line)) {
                    return $pos + 1;
                }
            }
        }

        throw new \Liip\RMT\Exception('Invalid changelog formatting');
    }
protected function findPositionToInsert ( $ lines , $ type ) { // Major are always inserted at the top if ( $ type == 'major' ) { return 0 ; } // Minor must be inserted one line above the first major section if ( $ type == 'minor' ) { foreach ( $ lines as $ pos => $ line ) { if ( preg_match ( '/^=======/' , $ line ) ) { return $ pos + 1 ; } } } // Patch should go directly after the first minor if ( $ type == 'patch' ) { foreach ( $ lines as $ pos => $ line ) { if ( preg_match ( '/Version\s\d+\.\d+\s\-/' , $ line ) ) { return $ pos + 1 ; } } } throw new \ Liip \ RMT \ Exception ( 'Invalid changelog formatting' ) ; }
Return the position where to insert new lines according to the type of insertion

@param array  $lines Existing lines
@param string $type  Release type

@return int The position where to insert

@throws \Liip\RMT\Exception
Return the position where to insert new lines according to the type of insertion