Code Duplication    Length = 9-12 lines in 2 locations

src/Xml/XmlContext.php 2 locations

@@ 143-151 (lines=9) @@
140
     *
141
     * @Then /^the XML attribute "(?P<attribute>[^"]*)" on element "(?P<element>(?:[^"]|\\")*)" should exists?$/
142
     */
143
    public function theXmlAttributeShouldExist($attribute, $element)
144
    {
145
        $elements = $this->theXmlElementShouldExist("{$element}[@{$attribute}]");
146
        $actual = $elements->item(0)->getAttribute($attribute);
147
        if (empty($actual)) {
148
            throw new \Exception(sprintf("The attribute value is `%s`", $actual));
149
        }
150
        return $actual;
151
    }
152
153
    /**
154
     * Checks that the XML attribute on the specified element does not exist
@@ 158-169 (lines=12) @@
155
     *
156
     * @Then /^the XML attribute "(?P<attribute>[^"]*)" on element "(?P<element>(?:[^"]|\\")*)" should not exists?$/
157
     */
158
    public function theXmlAttributeShouldNotExist($attribute, $element)
159
    {
160
        try {
161
            $elements = $this->theXmlElementShouldExist("{$element}[@{$attribute}]");
162
            $actual = $elements->item(0)->getAttribute($attribute);
163
            if (!empty($actual)) {
164
                throw new \Exception(sprintf("The element '%s' exists and contains '%s'.", $element , $elements));
165
            }
166
        }
167
        catch (\Exception $e) {
168
        }
169
    }
170
171
    /**
172
     * Checks that the XML attribute on the specified element is equal to the given value