Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
58.82% covered (warning)
58.82%
10 / 17
53.33% covered (warning)
53.33%
8 / 15
CRAP
0.00% covered (danger)
0.00%
0 / 1
Plugin_Headers
58.82% covered (warning)
58.82%
10 / 17
53.33% covered (warning)
53.33%
8 / 15
33.87
0.00% covered (danger)
0.00%
0 / 1
 __construct
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 get_by_name
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 get_name
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 get_plugin_uri
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 get_version
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 get_description
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 get_author
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 get_author_uri
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 get_text_domain
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 get_domain_path
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 get_network
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 get_requires_wp
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 get_requires_php
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 get_update_uri
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 get_requires_plugins
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
1 / 1
2
1<?php
2/**
3 * Strongly typed representation of the plugin headers.
4 *
5 * @package brianhenryie/bh-wp-plugin-updater
6 */
7
8namespace BrianHenryIE\WP_Plugin_Updater\Model;
9
10/**
11 * The only required header is 'Name', so all others are nullable
12 */
13class Plugin_Headers {
14
15    public function __construct(
16        protected array $header_array,
17    ) {
18    }
19    public function get_by_name( string $header_name ): ?string {
20        return $this->header_array[ $header_name ] ?? null;
21    }
22
23    /** Plugin Name */
24    public function get_name(): ?string {
25        return $this->header_array['Name'] ?? null;
26    }
27
28    /** Plugin URI */
29    public function get_plugin_uri(): ?string {
30        return $this->header_array['PluginURI'] ?? null;
31    }
32
33    /** Version */
34    public function get_version(): ?string {
35        return $this->header_array['Version'] ?? null;
36    }
37
38    /** Description */
39    public function get_description(): ?string {
40        return $this->header_array['Description'] ?? null;
41    }
42
43    /** Author */
44    public function get_author(): ?string {
45        return $this->header_array['Author'] ?? null;
46    }
47
48    /** Author URI */
49    public function get_author_uri(): ?string {
50        return $this->header_array['AuthorURI'] ?? null;
51    }
52
53    /** Text Domain */
54    public function get_text_domain(): ?string {
55        return $this->header_array['TextDomain'] ?? null;
56    }
57
58    /** Domain Path */
59    public function get_domain_path(): ?string {
60        return $this->header_array['DomainPath'] ?? null;
61    }
62
63    /** Network */
64    public function get_network(): ?string {
65        return $this->header_array['Network'] ?? null;
66    }
67
68    /** Requires at least */
69    public function get_requires_wp(): ?string {
70        return $this->header_array['RequiresWP'] ?? null;
71    }
72
73    /** Requires PHP */
74    public function get_requires_php(): ?string {
75        return $this->header_array['RequiresPHP'] ?? null;
76    }
77
78    /** Update URI */
79    public function get_update_uri(): ?string {
80        return $this->header_array['UpdateURI'] ?? null;
81    }
82
83    /** Requires Plugins */
84    public function get_requires_plugins(): array {
85        return $this->header_array['RequiresPlugins'] ?? false
86            ? array_map( 'trim', explode( ',', $this->header_array['RequiresPlugins'] ) )
87            : array();
88    }
89}