Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
50.00% |
4 / 8 |
|
50.00% |
4 / 8 |
CRAP | |
0.00% |
0 / 1 |
Settings | |
50.00% |
4 / 8 |
|
50.00% |
4 / 8 |
19.12 | |
0.00% |
0 / 1 |
get_usps_username | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
get_easypost_api_key | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
is_admin_email_enabled | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
get_log_level | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
get_plugin_name | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
get_plugin_slug | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
get_plugin_version | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
2 | |||
get_plugin_basename | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 |
1 | <?php |
2 | /** |
3 | * TODO: Add an option to hide "bad address" from users. |
4 | */ |
5 | |
6 | namespace BrianHenryIE\WC_Address_Validation\API; |
7 | |
8 | use BrianHenryIE\WC_Address_Validation\Settings_Interface; |
9 | use BrianHenryIE\WC_Address_Validation\WP_Logger\WooCommerce_Logger_Settings_Interface; |
10 | use Psr\Log\LogLevel; |
11 | |
12 | class Settings implements Settings_Interface, WooCommerce_Logger_Settings_Interface { |
13 | |
14 | // TODO: Convert to underscores. |
15 | const USPS_USERNAME_OPTION = 'bh_wc_address_validation_usps_username'; |
16 | const EASYPOST_API_KEY_OPTION = 'bh_wc_address_validation_easypost_api_key'; |
17 | |
18 | const IS_ADMIN_EMAIL_ENABLED_OPTION = 'bh-wc-address-validation-is-admin-email-enabled'; |
19 | |
20 | /** |
21 | * @return string |
22 | */ |
23 | public function get_usps_username(): ?string { |
24 | return get_option( self::USPS_USERNAME_OPTION ); |
25 | } |
26 | |
27 | public function get_easypost_api_key(): ?string { |
28 | return get_option( self::EASYPOST_API_KEY_OPTION ); |
29 | } |
30 | |
31 | public function is_admin_email_enabled(): bool { |
32 | // TODO: This should set and read from the WC_Email settings. |
33 | return get_option( self::IS_ADMIN_EMAIL_ENABLED_OPTION, false ); |
34 | } |
35 | |
36 | |
37 | /** |
38 | * |
39 | * @see Logger_Settings_Interface |
40 | * |
41 | * @return string |
42 | */ |
43 | public function get_log_level(): string { |
44 | |
45 | return get_option( 'bh-wc-address-validation-log-level', LogLevel::NOTICE ); |
46 | } |
47 | |
48 | /** |
49 | * @see Logger_Settings_Interface |
50 | * |
51 | * @return string |
52 | */ |
53 | public function get_plugin_name(): string { |
54 | return 'Address Validation'; |
55 | } |
56 | |
57 | /** |
58 | * @see Logger_Settings_Interface |
59 | * |
60 | * @return string |
61 | */ |
62 | public function get_plugin_slug(): string { |
63 | return 'bh-wc-address-validation'; |
64 | } |
65 | |
66 | /** |
67 | * Updates? |
68 | * |
69 | * @return string |
70 | */ |
71 | public function get_plugin_version(): string { |
72 | return defined( 'BH_WC_ADDRESS_VALIDATION_VERSION' ) ? BH_WC_ADDRESS_VALIDATION_VERSION : '1.4.1'; |
73 | } |
74 | |
75 | /** |
76 | * The plugin basename is used by the logger to add the plugins page action link. |
77 | * (and maybe for PHP errors) |
78 | * |
79 | * @return string |
80 | * @see Logger |
81 | */ |
82 | public function get_plugin_basename(): string { |
83 | return 'bh-wc-address-validation/bh-wc-address-validation.php'; |
84 | } |
85 | } |