PluginProbe
Solid Performance – Your No-Code Caching, Performance, & Page Speed Solution / 1.5.0
Solid Performance – Your No-Code Caching, Performance, & Page Speed Solution v1.5.0
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 / Http / Header_Factory.php

Header_Factory.php in Solid Performance – Your No-Code Caching, Performance, & Page Speed Solution 1.5.0, at src/Performance/Http/Header_Factory.php

58 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 * Creates a header instance with response headers.
4 *
5 * @since 1.0.0
6 *
7 * @package SolidWP\Performance
8 */
9
10 declare( strict_types=1 );
11
12 namespace SolidWP\Performance\Http;
13
14 use SolidWP\Performance\Container;
15
16 /**
17 * Creates a header instance using response headers.
18 *
19 * @since 1.0.0
20 *
21 * @package SolidWP\Performance
22 */
23 class Header_Factory {
24
25 /**
26 * @var Container
27 */
28 private Container $container;
29
30 /**
31 * @param Container $container The container.
32 */
33 public function __construct( Container $container ) {
34 $this->container = $container;
35 }
36
37 /**
38 * Make a header instance using response headers.
39 *
40 * @note headers_list() does not work in CLI.
41 *
42 * @return Header
43 */
44 public function make(): Header {
45 $headers = headers_list();
46
47 $this->container->when( Header::class )
48 ->needs( '$headers' )
49 ->give( static fn(): array => $headers );
50
51 $header = $this->container->get( Header::class );
52
53 $this->container->singleton( Header::class, $header );
54
55 return $header;
56 }
57 }
58