PluginProbe
QuadMenu – Mega Menu / 3.3.8
QuadMenu – Mega Menu v3.3.8
3.3.8 3.3.7 3.3.6 trunk 1.8.4 1.8.5 1.8.7 1.8.8 1.8.9 1.9.0 1.9.2 1.9.3 1.9.4 1.9.5 1.9.6 1.9.7 1.9.8 1.9.9 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 All 88 releases
quadmenu / vendor / franmastromarino / wp-plugin-feedback / src / Client.php

Client.php in QuadMenu – Mega Menu 3.3.8, at vendor/franmastromarino/wp-plugin-feedback/src/Client.php

49 lines 1.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace QuadLayers\PluginFeedback;
4
5 class Client
6 {
7 /** @var Collector */
8 private $collector;
9 /** @var Validator */
10 private $validator;
11 /** @var Request */
12 private $request;
13
14 /**
15 * Constructor to initialize the client with plugin slug and version.
16 *
17 * @param string $pluginBasename The plugin slug.
18 */
19 public function __construct(
20 string $pluginBasename
21 ) {
22 $this->collector = new Collector($pluginBasename);
23 $this->validator = new Validator();
24 $this->request = new Request();
25 }
26
27 /**
28 * Sends feedback to the server.
29 *
30 * @param bool $isAnonymous Determines if the feedback is anonymous.
31 * @param string $feedbackReason The reason for the feedback.
32 * @param string $feedbackDetails Additional details for the feedback.
33 * @return bool True if the feedback was sent successfully, False otherwise.
34 */
35 public function sendFeedback(string $feedbackReason = '', string $feedbackDetails = '', $isAnonymous = false, $hasFeedback = false) : bool
36 {
37 // Collect data
38 $data = $this->collector->collectData($feedbackReason, $feedbackDetails, $isAnonymous, $hasFeedback);
39
40 // Validate data
41 if (!$this->validator->validate($data, $isAnonymous)) {
42 return false;
43 }
44
45 // Send data
46 return $this->request->send($data);
47 }
48 }
49