• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

equalizedigital / accessibility-checker / 14915400893

08 May 2025 08:21PM UTC coverage: 28.872%. First build
14915400893

Pull #966

github

web-flow
Merge 5d3580e41 into f6dc26e5a
Pull Request #966: Release v1.23.0

55 of 158 new or added lines in 10 files covered. (34.81%)

1495 of 5178 relevant lines covered (28.87%)

1.49 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/includes/classes/class-dom-wrapper.php
1
<?php
2
/**
3
 * DOM Wrapper class to provide Simple HTML DOM compatibility.
4
 *
5
 * This class serves as a wrapper to enhance compatibility with Simple HTML DOM.
6
 *
7
 * @package Accessibility_Checker
8
 * @since 1.23.0
9
 */
10

11
namespace EDAC\Inc;
12

13
/**
14
 * Wrapper class for DOMDocument to provide Simple HTML DOM interface compatibility
15
 */
16
class DOM_Wrapper {
17
        /**
18
         * The wrapped DOMDocument instance
19
         *
20
         * @var \DOMDocument
21
         */
22
        private $dom;
23

24
        /**
25
         * Constructor
26
         *
27
         * @param \DOMDocument $dom The DOMDocument to wrap.
28
         */
29
        public function __construct( \DOMDocument $dom ) {
NEW
30
                $this->dom = $dom;
×
31
        }
32

33
        /**
34
         * Find elements by selector (Simple HTML DOM compatibility method)
35
         *
36
         * @param string $selector The selector to search for.
37
         * @param int    $idx The index to return (optional).
38
         * @return array|\DOMElement|null
39
         */
40
        public function find( $selector, $idx = null ) {
NEW
41
                $xpath = new \DOMXPath( $this->dom );
×
42
                
43
                // Convert simple selectors to XPath.
NEW
44
                if ( strpos( $selector, '.' ) === 0 ) {
×
45
                        // Class selector.
NEW
46
                        $query = "//*[contains(@class, '" . htmlspecialchars( substr( $selector, 1 ), ENT_QUOTES, 'UTF-8' ) . "')]";
×
47
                } else {
48
                        // Tag selector.
NEW
49
                        $query = "//{$selector}";
×
50
                }
51
                
NEW
52
                $elements = $xpath->query( $query );
×
53

NEW
54
                if ( false === $elements ) {
×
NEW
55
                        return null;
×
56
                }
57
                
NEW
58
                if ( null !== $idx ) {
×
NEW
59
                        return $elements->item( $idx );
×
60
                }
61
                
NEW
62
                return iterator_to_array( $elements );
×
63
        }
64

65
        /**
66
         * Get the underlying DOMDocument
67
         *
68
         * @return \DOMDocument
69
         */
70
        public function get_dom() {
NEW
71
                return $this->dom;
×
72
        }
73
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc