PluginProbe
Solid Performance – Your No-Code Caching, Performance, & Page Speed Solution / trunk
Solid Performance – Your No-Code Caching, Performance, & Page Speed Solution vtrunk
2.0.1 trunk 1.0.0 1.1.0 1.2.0 1.3.0 1.3.1 1.3.2 1.3.3 1.4.0 1.4.1 1.4.2 1.5.0 1.6.0 1.6.1 1.7.0 1.7.1 1.8.0 1.9.0 2.0.0
solid-performance / src / Performance / Preload / Trigger_Url.php

Trigger_Url.php in Solid Performance – Your No-Code Caching, Performance, & Page Speed Solution trunk, at src/Performance/Preload/Trigger_Url.php

52 lines 1.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * The base URL to use to trigger a preload batch.
4 *
5 * @package SolidWP\Performance
6 */
7
8 declare( strict_types=1 );
9
10 namespace SolidWP\Performance\Preload;
11
12 use InvalidArgumentException;
13
14 /**
15 * The base URL to use to trigger a preload batch.
16 *
17 * @package SolidWP\Performance
18 */
19 final class Trigger_Url {
20
21 /**
22 * @var string
23 */
24 private string $trigger_url;
25
26 /**
27 * @param string $trigger_url The base URL to use to trigger a preload batch.
28 *
29 * @throws InvalidArgumentException If the trigger URL is empty.
30 */
31 public function __construct( string $trigger_url ) {
32 if ( strlen( $trigger_url ) === 0 ) {
33 throw new InvalidArgumentException( 'The trigger URL cannot be empty' );
34 }
35
36 if ( esc_url_raw( $trigger_url, [ 'http', 'https' ] ) !== $trigger_url ) {
37 throw new InvalidArgumentException( 'The trigger URL is not a valid URL' );
38 }
39
40 $this->trigger_url = $trigger_url;
41 }
42
43 /**
44 * Get the trigger URL.
45 *
46 * @return string
47 */
48 public function get(): string {
49 return $this->trigger_url;
50 }
51 }
52