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

@@ 248-272 (lines=25) @@
245
     *
246
     * @throws \Exception
247
     */
248
    public function validate(XMLSecurityKey $key)
249
    {
250
        if (count($this->validators) === 0) {
251
            return false;
252
        }
253
254
        $exceptions = array();
255
256
        foreach ($this->validators as $validator) {
257
            $function = $validator['Function'];
258
            $data = $validator['Data'];
259
260
            try {
261
                call_user_func($function, $data, $key);
262
                /* We were able to validate the message with this validator. */
263
264
                return true;
265
            } catch (\Exception $e) {
266
                $exceptions[] = $e;
267
            }
268
        }
269
270
        /* No validators were able to validate the message. */
271
        throw $exceptions[0];
272
    }
273
274
    /**
275
     * Retrieve the identifier of this message.