Code Duplication    Length = 25-25 lines in 2 locations

src/SAML2/SignedElementHelper.php 1 location

@@ 98-122 (lines=25) @@
95
     * @return boolean        true on success, false when we don't have a signature.
96
     * @throws \Exception
97
     */
98
    public function validate(XMLSecurityKey $key)
99
    {
100
        if (count($this->validators) === 0) {
101
            return false;
102
        }
103
104
        $exceptions = array();
105
106
        foreach ($this->validators as $validator) {
107
            $function = $validator['Function'];
108
            $data = $validator['Data'];
109
110
            try {
111
                call_user_func($function, $data, $key);
112
                /* We were able to validate the message with this validator. */
113
114
                return true;
115
            } catch (\Exception $e) {
116
                $exceptions[] = $e;
117
            }
118
        }
119
120
        /* No validators were able to validate the message. */
121
        throw $exceptions[0];
122
    }
123
124
    /**
125
     * Retrieve the private key we should use to sign the message.

src/SAML2/Message.php 1 location

@@ 228-252 (lines=25) @@
225
     * @return boolean        true on success, false when we don't have a signature.
226
     * @throws \Exception
227
     */
228
    public function validate(XMLSecurityKey $key)
229
    {
230
        if (count($this->validators) === 0) {
231
            return false;
232
        }
233
234
        $exceptions = array();
235
236
        foreach ($this->validators as $validator) {
237
            $function = $validator['Function'];
238
            $data = $validator['Data'];
239
240
            try {
241
                call_user_func($function, $data, $key);
242
                /* We were able to validate the message with this validator. */
243
244
                return true;
245
            } catch (\Exception $e) {
246
                $exceptions[] = $e;
247
            }
248
        }
249
250
        /* No validators were able to validate the message. */
251
        throw $exceptions[0];
252
    }
253
254
    /**
255
     * Retrieve the identifier of this message.