PluginProbe ʕ •ᴥ•ʔ
Aruba HiSpeed Cache / 3.0.15
Aruba HiSpeed Cache v3.0.15
3.0.15 3.0.14 3.0.13 1.2.4 1.2.5 1.2.6 2.0.0 2.0.1 2.0.10 2.0.11 2.0.12 2.0.13 2.0.14 2.0.15 2.0.16 2.0.17 2.0.18 2.0.19 2.0.20 2.0.21 2.0.22 2.0.23 2.0.24 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 2.0.8 2.0.9 3.0.0 3.0.1 3.0.10 3.0.11 3.0.12 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 trunk 1.0.0 1.1.0 1.1.1 1.1.2 1.2.0 1.2.1 1.2.2 1.2.3
aruba-hispeed-cache / src / Purger / AbstractPurger.php
aruba-hispeed-cache / src / Purger Last commit date
AbstractPurger.php 3 days ago WpPurger.php 3 days ago
AbstractPurger.php
181 lines
1 <?php //@phpcs:ignore WordPress.Files.FileName.NotHyphenatedLowercase
2 /**
3 * ArubaHiSpeedCacheWpPurger
4 * php version 7.4
5 *
6 * @category Wordpress-plugin
7 * @package Aruba-HiSpeed-Cache
8 * @author Aruba Developer <hispeedcache.developer@aruba.it>
9 * @license https://www.gnu.org/licenses/gpl-3.0.html GPLv3
10 * @link \ArubaHiSpeedCache\Run_Aruba_Hispeed_cache()
11 * @since 1.1.3
12 */
13
14 namespace ArubaSPA\HiSpeedCache\Purger;
15
16 // Unqualified defined() on purpose: inside a namespace PHP still resolves it to the
17 // global function, and Plugin Check only recognises this exact guard shape.
18 if ( ! defined( 'ABSPATH' ) ) {
19 exit;
20 }
21
22 if ( ! \class_exists( __NAMESPACE__ . 'AbstractPurger' ) ) {
23 // phpcs:disable WordPress.NamingConventions
24 /**
25 * AbstracPurger.
26 */
27 abstract class AbstractPurger {
28 /**
29 * $servr_host for the requst
30 *
31 * @var string
32 */
33 protected $serverHost;
34
35 /**
36 * $server_port for the request
37 *
38 * @var string
39 */
40 protected $serverPort;
41
42 /**
43 * $time_out of request
44 *
45 * @var integer
46 */
47 protected $timeOut;
48
49 /**
50 * Purge the cache of a single page
51 *
52 * @param string $url The url to purge.
53 * @return void
54 */
55 abstract public function purgeUrl( $url );
56
57 /**
58 * Purge the cache of a list of pages
59 *
60 * @param array $urls The urls to purge.
61 * @return void
62 */
63 abstract public function purgeUrls( $urls );
64
65 /**
66 * Purge the alla chace of site
67 *
68 * @return void
69 */
70 abstract public function purgeAll();
71
72 /**
73 * DoRemoteGet
74 *
75 * @param string $target path to purge.
76 *
77 * @return void
78 */
79 abstract public function doRemoteGet( $target = '/' );
80
81 /**
82 * PreparePurgeRequestUri
83 *
84 * @param string $url Url to prepare.
85 *
86 * @return string for the purge request.
87 */
88 public function preparePurgeRequestUri( $url ) {
89 return \sprintf(
90 'http://%s:%s/purge%s',
91 $this->getServerHost(),
92 $this->getServerPort(),
93 preg_replace( '|^(https?:)?//[^/]+(/?.*)|i', '$2', filter_var( $url, FILTER_SANITIZE_URL ) )
94 );
95 }
96
97 /**
98 * Set the purger.
99 *
100 * $config [
101 * 'time_out' => int 5;
102 * 'server_host' => string '127.0.0.1'
103 * 'server_port' => string '8889'
104 * ];
105 *
106 * @param array $configs The confi for the purger.
107 * @return void
108 */
109 public function setPurger( $configs ) {
110 $this->setTimeOut( $configs['time_out'] );
111 $this->setServerHost( $configs['server_host'] );
112 $this->setServerPort( $configs['server_port'] );
113 }
114
115 /**
116 * Get undocumented variable
117 *
118 * @return integer
119 */
120 public function getTimeOut() {
121 return $this->timeOut;
122 }
123
124 /**
125 * Set undocumented variable
126 *
127 * @param integer $timeOut Undocumented variable.
128 *
129 * @return self
130 */
131 public function setTimeOut( $timeOut ) {
132 $this->timeOut = $timeOut;
133
134 return $this;
135 }
136
137 /**
138 * Get undocumented variable
139 *
140 * @return string
141 */
142 public function getServerPort() {
143 return $this->serverPort;
144 }
145
146 /**
147 * Set undocumented variable
148 *
149 * @param string $serverPort Undocumented variable.
150 *
151 * @return self
152 */
153 public function setServerPort( $serverPort ) {
154 $this->serverPort = $serverPort;
155 return $this;
156 }
157
158 /**
159 * Get undocumented variable
160 *
161 * @return string
162 */
163 public function getServerHost() {
164 return $this->serverHost;
165 }
166
167 /**
168 * Set undocumented variable
169 *
170 * @param string $serverHost Undocumented variable.
171 *
172 * @return self
173 */
174 public function setServerHost( $serverHost ) {
175 $this->serverHost = $serverHost;
176 return $this;
177 }
178 }
179 // phpcs:enable
180 }
181