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

Yoast / wordpress-seo / da4efbc5b07d9422360e8da09157e996aa6d4c8e

13 May 2026 09:45AM UTC coverage: 50.158%. First build
da4efbc5b07d9422360e8da09157e996aa6d4c8e

Pull #23265

github

web-flow
Merge c231415c9 into b17f347fb
Pull Request #23265: feat: authenticate yoast-ai requests with MyYoast OAuth tokens

129 of 246 new or added lines in 16 files covered. (52.44%)

20769 of 41407 relevant lines covered (50.16%)

4.0 hits per line

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

0.0
/src/ai/http-request/domain/request.php
1
<?php
2

3
// phpcs:disable Yoast.NamingConventions.NamespaceName.TooLong -- Needed in the folder structure.
4

5
namespace Yoast\WP\SEO\AI\HTTP_Request\Domain;
6

7
/**
8
 * Class Request
9
 * Represents a request to the AI Generator API.
10
 */
11
class Request {
12

13
        /**
14
         * The action path for the request.
15
         *
16
         * @var string
17
         */
18
        private $action_path;
19

20
        /**
21
         * The body of the request.
22
         *
23
         * @var array<string>
24
         */
25
        private $body;
26

27
        /**
28
         * The headers for the request.
29
         *
30
         * @var array<string>
31
         */
32
        private $headers;
33

34
        /**
35
         * Whether the request is a POST request.
36
         *
37
         * @var bool
38
         */
39
        private $is_post;
40

41
        /**
42
         * Constructor for the Request class.
43
         *
44
         * @param string        $action_path The action path for the request.
45
         * @param array<string> $body        The body of the request.
46
         * @param array<string> $headers     The headers for the request.
47
         * @param bool          $is_post     Whether the request is a POST request. Default is true.
48
         */
49
        public function __construct( string $action_path, array $body = [], array $headers = [], bool $is_post = true ) {
×
50
                $this->action_path = $action_path;
×
51
                $this->body        = $body;
×
52
                $this->headers     = $headers;
×
53
                $this->is_post     = $is_post;
×
54
        }
55

56
        /**
57
         * Get the action path for the request.
58
         *
59
         * @return string The action path for the request.
60
         */
61
        public function get_action_path(): string {
×
62
                return $this->action_path;
×
63
        }
64

65
        /**
66
         * Get the body of the request.
67
         *
68
         * @return array<string> The body of the request.
69
         */
70
        public function get_body(): array {
×
71
                return $this->body;
×
72
        }
73

74
        /**
75
         * Get the headers for the request.
76
         *
77
         * @return array<string> The headers for the request.
78
         */
79
        public function get_headers(): array {
×
80
                return $this->headers;
×
81
        }
82

83
        /**
84
         * Whether the request is a POST request.
85
         *
86
         * @return bool True if the request is a POST request, false otherwise.
87
         */
88
        public function is_post(): bool {
×
89
                return $this->is_post;
×
90
        }
91

92
        /**
93
         * Returns a copy of the request with the given headers merged in.
94
         *
95
         * @param array<string> $headers The headers to add.
96
         *
97
         * @return self The new request.
98
         */
NEW
99
        public function with_added_headers( array $headers ): self {
×
NEW
100
                return new self(
×
NEW
101
                        $this->action_path,
×
NEW
102
                        $this->body,
×
NEW
103
                        \array_merge( $this->headers, $headers ),
×
NEW
104
                        $this->is_post,
×
NEW
105
                );
×
106
        }
107

108
        /**
109
         * Returns a copy of the request with the given body fields merged in.
110
         *
111
         * @param array<string> $body The body fields to add.
112
         *
113
         * @return self The new request.
114
         */
NEW
115
        public function with_added_body( array $body ): self {
×
NEW
116
                return new self(
×
NEW
117
                        $this->action_path,
×
NEW
118
                        \array_merge( $this->body, $body ),
×
NEW
119
                        $this->headers,
×
NEW
120
                        $this->is_post,
×
NEW
121
                );
×
122
        }
123
}
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