Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
4 / 4 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
| Request | |
100.00% |
4 / 4 |
|
100.00% |
2 / 2 |
4 | |
100.00% |
1 / 1 |
| get_base_url | |
100.00% |
3 / 3 |
|
100.00% |
1 / 1 |
3 | |||
| get_endpoint | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| get_md5_hash | n/a |
0 / 0 |
n/a |
0 / 0 |
0 | |||||
| 1 | <?php |
| 2 | |
| 3 | namespace NewfoldLabs\WP\Module\Data\WonderBlocks\Requests; |
| 4 | |
| 5 | /** |
| 6 | * Base class for WonderBlock Requests. |
| 7 | */ |
| 8 | abstract class Request { |
| 9 | /** |
| 10 | * The production base URL. |
| 11 | * |
| 12 | * @var string |
| 13 | */ |
| 14 | protected static $production_base_url = 'https://patterns.hiive.cloud'; |
| 15 | |
| 16 | /** |
| 17 | * The local base URL. |
| 18 | * |
| 19 | * @var string |
| 20 | */ |
| 21 | protected static $local_base_url = 'http://localhost:8888'; |
| 22 | |
| 23 | /** |
| 24 | * The endpoint to request. |
| 25 | * |
| 26 | * @var string |
| 27 | */ |
| 28 | protected $endpoint; |
| 29 | |
| 30 | /** |
| 31 | * Get the base URL |
| 32 | */ |
| 33 | public function get_base_url(): string { |
| 34 | if ( defined( 'NFD_DATA_WB_DEV_MODE' ) && constant( 'NFD_DATA_WB_DEV_MODE' ) ) { |
| 35 | return self::$local_base_url; |
| 36 | } |
| 37 | |
| 38 | return self::$production_base_url; |
| 39 | } |
| 40 | |
| 41 | /** |
| 42 | * Get the request endpoint. |
| 43 | */ |
| 44 | public function get_endpoint(): string { |
| 45 | return $this->endpoint; |
| 46 | } |
| 47 | |
| 48 | /** |
| 49 | * This function should return a MD5 hashed string of the request parameters that can uniquely identify it. |
| 50 | */ |
| 51 | abstract public function get_md5_hash(): string; |
| 52 | } |