| 1 |
<?php |
| 2 |
/** |
| 3 |
* A factory to create a Meta Value Object. |
| 4 |
* |
| 5 |
* @package SolidWP\Performance |
| 6 |
*/ |
| 7 |
|
| 8 |
declare( strict_types=1 ); |
| 9 |
|
| 10 |
namespace SolidWP\Performance\Page_Cache\Meta; |
| 11 |
|
| 12 |
use InvalidArgumentException; |
| 13 |
use SolidWP\Performance\Http\Header_Factory; |
| 14 |
|
| 15 |
/** |
| 16 |
* A factory to create a Meta Value Object. |
| 17 |
* |
| 18 |
* @see Meta |
| 19 |
* |
| 20 |
* @package SolidWP\Performance |
| 21 |
*/ |
| 22 |
class Meta_Factory { |
| 23 |
|
| 24 |
/** |
| 25 |
* @var Header_Factory |
| 26 |
*/ |
| 27 |
private Header_Factory $header_factory; |
| 28 |
|
| 29 |
/** |
| 30 |
* @param Header_Factory $header_factory The header factory. |
| 31 |
*/ |
| 32 |
public function __construct( Header_Factory $header_factory ) { |
| 33 |
$this->header_factory = $header_factory; |
| 34 |
} |
| 35 |
|
| 36 |
/** |
| 37 |
* Make a Meta Value Object. |
| 38 |
* |
| 39 |
* @param string $url The URL associated with the meta. |
| 40 |
* |
| 41 |
* @throws InvalidArgumentException If the $url is empty. |
| 42 |
* |
| 43 |
* @return Meta |
| 44 |
*/ |
| 45 |
public function make( string $url ): Meta { |
| 46 |
return Meta::from( |
| 47 |
[ |
| 48 |
'url' => $url, |
| 49 |
'headers' => $this->header_factory->make(), |
| 50 |
] |
| 51 |
); |
| 52 |
} |
| 53 |
} |
| 54 |
|