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

Yoast / wordpress-seo / dd6e866a9e6d253114633104d9e3858d807178ba

19 Jun 2024 10:03AM UTC coverage: 48.628% (-4.3%) from 52.936%
dd6e866a9e6d253114633104d9e3858d807178ba

push

github

web-flow
Merge pull request #21431 from Yoast/21429-update-copy-in-the-introduction-and-consent-modals

Updates the copy for the introduction and consent modals

7441 of 13454 branches covered (55.31%)

Branch coverage included in aggregate %.

0 of 3 new or added lines in 2 files covered. (0.0%)

3718 existing lines in 107 files now uncovered.

25100 of 53464 relevant lines covered (46.95%)

62392.47 hits per line

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

0.0
/inc/sitemaps/class-sitemap-cache-data.php
1
<?php
2
/**
3
 * WPSEO plugin file.
4
 *
5
 * @package WPSEO\XML_Sitemaps
6
 */
7

8
/**
9
 * Sitemap Cache Data object, manages sitemap data stored in cache.
10
 */
11
class WPSEO_Sitemap_Cache_Data implements Serializable, WPSEO_Sitemap_Cache_Data_Interface {
12

13
        /**
14
         * Sitemap XML data.
15
         *
16
         * @var string
17
         */
18
        private $sitemap = '';
19

20
        /**
21
         * Status of the sitemap, usable or not.
22
         *
23
         * @var string
24
         */
25
        private $status = self::UNKNOWN;
26

27
        /**
28
         * Set the sitemap XML data
29
         *
30
         * @param string $sitemap XML Content of the sitemap.
31
         *
32
         * @return void
33
         */
UNCOV
34
        public function set_sitemap( $sitemap ) {
×
35

UNCOV
36
                if ( ! is_string( $sitemap ) ) {
×
37
                        $sitemap = '';
×
38
                }
39

UNCOV
40
                $this->sitemap = $sitemap;
×
41

42
                /*
43
                 * Empty sitemap is not usable.
44
                 */
UNCOV
45
                if ( ! empty( $sitemap ) ) {
×
UNCOV
46
                        $this->set_status( self::OK );
×
47
                }
48
                else {
UNCOV
49
                        $this->set_status( self::ERROR );
×
50
                }
51
        }
52

53
        /**
54
         * Set the status of the sitemap, is it usable.
55
         *
56
         * @param bool|string $usable Is the sitemap usable or not.
57
         *
58
         * @return void
59
         */
UNCOV
60
        public function set_status( $usable ) {
×
61

UNCOV
62
                if ( $usable === self::OK ) {
×
UNCOV
63
                        $this->status = self::OK;
×
64

UNCOV
65
                        return;
×
66
                }
67

UNCOV
68
                if ( $usable === self::ERROR ) {
×
UNCOV
69
                        $this->status  = self::ERROR;
×
UNCOV
70
                        $this->sitemap = '';
×
71

UNCOV
72
                        return;
×
73
                }
74

75
                $this->status = self::UNKNOWN;
×
76
        }
77

78
        /**
79
         * Is the sitemap usable.
80
         *
81
         * @return bool True if usable, False if bad or unknown.
82
         */
UNCOV
83
        public function is_usable() {
×
84

UNCOV
85
                return $this->status === self::OK;
×
86
        }
87

88
        /**
89
         * Get the XML content of the sitemap.
90
         *
91
         * @return string The content of the sitemap.
92
         */
UNCOV
93
        public function get_sitemap() {
×
94

UNCOV
95
                return $this->sitemap;
×
96
        }
97

98
        /**
99
         * Get the status of the sitemap.
100
         *
101
         * @return string Status of the sitemap, 'ok'/'error'/'unknown'.
102
         */
UNCOV
103
        public function get_status() {
×
104

UNCOV
105
                return $this->status;
×
106
        }
107

108
        /**
109
         * String representation of object.
110
         *
111
         * {@internal This magic method is only "magic" as of PHP 7.4 in which the magic method was introduced.}
112
         *
113
         * @link https://www.php.net/language.oop5.magic#object.serialize
114
         * @link https://wiki.php.net/rfc/custom_object_serialization
115
         *
116
         * @since 17.8.0
117
         *
118
         * @return array The data to be serialized.
119
         */
UNCOV
120
        public function __serialize() { // phpcs:ignore PHPCompatibility.FunctionNameRestrictions.NewMagicMethods.__serializeFound
×
121

UNCOV
122
                $data = [
×
UNCOV
123
                        'status' => $this->status,
×
UNCOV
124
                        'xml'    => $this->sitemap,
×
UNCOV
125
                ];
×
126

UNCOV
127
                return $data;
×
128
        }
129

130
        /**
131
         * Constructs the object.
132
         *
133
         * {@internal This magic method is only "magic" as of PHP 7.4 in which the magic method was introduced.}
134
         *
135
         * @link https://www.php.net/language.oop5.magic#object.serialize
136
         * @link https://wiki.php.net/rfc/custom_object_serialization
137
         *
138
         * @since 17.8.0
139
         *
140
         * @param array $data The unserialized data to use to (re)construct the object.
141
         *
142
         * @return void
143
         */
UNCOV
144
        public function __unserialize( $data ) { // phpcs:ignore PHPCompatibility.FunctionNameRestrictions.NewMagicMethods.__unserializeFound
×
145

UNCOV
146
                $this->set_sitemap( $data['xml'] );
×
UNCOV
147
                $this->set_status( $data['status'] );
×
148
        }
149

150
        /**
151
         * String representation of object.
152
         *
153
         * {@internal The magic methods take precedence over the Serializable interface.
154
         * This means that in practice, this method will now only be called on PHP < 7.4.
155
         * For PHP 7.4 and higher, the magic methods will be used instead.}
156
         *
157
         * {@internal The Serializable interface is being phased out, in favour of the magic methods.
158
         * This method should be deprecated and removed and the class should no longer
159
         * implement the `Serializable` interface.
160
         * This change, however, can't be made until the minimum PHP version goes up to PHP 7.4 or higher.}
161
         *
162
         * @link http://php.net/manual/en/serializable.serialize.php
163
         * @link https://wiki.php.net/rfc/phase_out_serializable
164
         *
165
         * @since 5.1.0
166
         *
167
         * @return string The string representation of the object or null in C-format.
168
         */
UNCOV
169
        public function serialize() {
×
170

UNCOV
171
                return serialize( $this->__serialize() );
×
172
        }
173

174
        /**
175
         * Constructs the object.
176
         *
177
         * {@internal The magic methods take precedence over the Serializable interface.
178
         * This means that in practice, this method will now only be called on PHP < 7.4.
179
         * For PHP 7.4 and higher, the magic methods will be used instead.}
180
         *
181
         * {@internal The Serializable interface is being phased out, in favour of the magic methods.
182
         * This method should be deprecated and removed and the class should no longer
183
         * implement the `Serializable` interface.
184
         * This change, however, can't be made until the minimum PHP version goes up to PHP 7.4 or higher.}
185
         *
186
         * @link http://php.net/manual/en/serializable.unserialize.php
187
         * @link https://wiki.php.net/rfc/phase_out_serializable
188
         *
189
         * @since 5.1.0
190
         *
191
         * @param string $data The string representation of the object in C or O-format.
192
         *
193
         * @return void
194
         */
UNCOV
195
        public function unserialize( $data ) {
×
196

UNCOV
197
                $data = unserialize( $data );
×
UNCOV
198
                $this->__unserialize( $data );
×
199
        }
200
}
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

© 2025 Coveralls, Inc