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

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