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

Yoast / wordpress-seo / 0fdb51d5ef87fb55b55da5a950cf7350c155980d

11 Mar 2025 10:16AM UTC coverage: 53.422% (-1.3%) from 54.687%
0fdb51d5ef87fb55b55da5a950cf7350c155980d

push

github

web-flow
Merge pull request #22086 from Yoast/add-pregnant-women-to-potentially-non-inclusive-phrases

Inclusive language: Add 'pregnant women' to potentially non-inclusive phrases

7918 of 13987 branches covered (56.61%)

Branch coverage included in aggregate %.

30526 of 57976 relevant lines covered (52.65%)

41097.18 hits per line

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

88.89
/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
         */
34
        public function set_sitemap( $sitemap ) {
4✔
35

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

40
                $this->sitemap = $sitemap;
4✔
41

42
                /*
43
                 * Empty sitemap is not usable.
44
                 */
45
                if ( ! empty( $sitemap ) ) {
4✔
46
                        $this->set_status( self::OK );
2✔
47
                }
48
                else {
49
                        $this->set_status( self::ERROR );
2✔
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
         */
60
        public function set_status( $usable ) {
6✔
61

62
                if ( $usable === self::OK ) {
6✔
63
                        $this->status = self::OK;
4✔
64

65
                        return;
4✔
66
                }
67

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

72
                        return;
2✔
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
         */
83
        public function is_usable() {
4✔
84

85
                return $this->status === self::OK;
4✔
86
        }
87

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

95
                return $this->sitemap;
4✔
96
        }
97

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

105
                return $this->status;
12✔
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
         */
120
        public function __serialize() { // phpcs:ignore PHPCompatibility.FunctionNameRestrictions.NewMagicMethods.__serializeFound
2✔
121

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

127
                return $data;
2✔
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
         */
144
        public function __unserialize( $data ) { // phpcs:ignore PHPCompatibility.FunctionNameRestrictions.NewMagicMethods.__unserializeFound
6✔
145

146
                $this->set_sitemap( $data['xml'] );
6✔
147
                $this->set_status( $data['status'] );
6✔
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
         */
169
        public function serialize() {
×
170

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
         */
195
        public function unserialize( $data ) {
2✔
196

197
                $data = unserialize( $data );
2✔
198
                $this->__unserialize( $data );
2✔
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

© 2026 Coveralls, Inc