Code Duplication    Length = 25-25 lines in 2 locations

src/Surfnet/StepupSelfService/SelfServiceBundle/Security/Authentication/Provider/SamlProvider.php 2 locations

@@ 116-140 (lines=25) @@
113
     * @param AssertionAdapter $translatedAssertion
114
     * @return string
115
     */
116
    private function getCommonName(AssertionAdapter $translatedAssertion)
117
    {
118
        $commonNames = $translatedAssertion->getAttributeValue('commonName');
119
120
        if (empty($commonNames)) {
121
            throw new BadCredentialsException(
122
                'No commonName provided'
123
            );
124
        }
125
126
        if (count($commonNames) > 1) {
127
            $this->logger->notice('Multiple commonNames provided, picking first one', ['commonNames' => $commonNames]);
128
        }
129
130
        $commonName = $commonNames[0];
131
132
        if (!is_string($commonName)) {
133
            $this->logger->notice('Received invalid commonName', ['commonName' => $commonName]);
134
            throw new BadCredentialsException(
135
                'commonName is not a string'
136
            );
137
        }
138
139
        return $commonName;
140
    }
141
142
    /**
143
     * @param AssertionAdapter $translatedAssertion
@@ 146-170 (lines=25) @@
143
     * @param AssertionAdapter $translatedAssertion
144
     * @return string
145
     */
146
    private function getEmail(AssertionAdapter $translatedAssertion)
147
    {
148
        $emails = $translatedAssertion->getAttributeValue('mail');
149
150
        if (empty($emails)) {
151
            throw new BadCredentialsException(
152
                'No schacHomeOrganization provided'
153
            );
154
        }
155
156
        if (count($emails) > 1) {
157
            $this->logger->notice('Multiple emails provided, picking first one', ['emails' => $emails]);
158
        }
159
160
        $email = $emails[0];
161
162
        if (!is_string($email)) {
163
            $this->logger->notice('Received invalid commonName', ['email' => $email]);
164
            throw new BadCredentialsException(
165
                'commonName is not a string'
166
            );
167
        }
168
169
        return $email;
170
    }
171
172
    /**
173
     * @param AssertionAdapter $translatedAssertion