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

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