Code Duplication    Length = 9-10 lines in 2 locations

src/Header/Consumer/AddressConsumer.php 1 location

@@ 101-109 (lines=9) @@
98
     * @param bool $isLiteral
99
     * @return \ZBateson\MailMimeParser\Header\Part\HeaderPart
100
     */
101
    protected function getPartForToken($token, $isLiteral)
102
    {
103
        if ($isLiteral) {
104
            return $this->partFactory->newLiteralPart($token);
105
        } elseif (preg_match('/^\s+$/', $token)) {
106
            return $this->partFactory->newToken(' ');
107
        }
108
        return $this->partFactory->newToken($token);
109
    }
110
    
111
    /**
112
     * Performs final processing on parsed parts.

src/Header/Consumer/GenericConsumer.php 1 location

@@ 81-90 (lines=10) @@
78
     * @param bool $isLiteral
79
     * @return \ZBateson\MailMimeParser\Header\Part\HeaderPart
80
     */
81
    protected function getPartForToken($token, $isLiteral)
82
    {
83
        if (preg_match('/^\s+$/', $token) && !$isLiteral) {
84
            return $this->partFactory->newToken(' ');
85
        } elseif ($isLiteral) {
86
            return $this->partFactory->newLiteralPart($token);
87
        } else {
88
            return $this->partFactory->newMimeLiteralPart($token);
89
        }
90
    }
91
    
92
    /**
93
     * Checks if the passed space part should be added to the returned parts and