Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
7 / 7
100.00% covered (success)
100.00%
2 / 2
CRAP
100.00% covered (success)
100.00%
1 / 1
Settings
100.00% covered (success)
100.00%
7 / 7
100.00% covered (success)
100.00%
2 / 2
2
100.00% covered (success)
100.00%
1 / 1
 __construct
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 get
100.00% covered (success)
100.00%
6 / 6
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2/**
3 * Class used to manage settings related to Account Protection.
4 *
5 * @package automattic/jetpack-account-protection
6 */
7
8namespace Automattic\Jetpack\Account_Protection;
9
10/**
11 * Account Protection Settings
12 */
13class Settings {
14    /**
15     * Account protection instance.
16     *
17     * @var Account_Protection
18     */
19    private $account_protection;
20
21    /**
22     * Constructor for dependency injection.
23     *
24     * @param ?Account_Protection|null $account_protection Account protection dependency.
25     */
26    public function __construct( ?Account_Protection $account_protection = null ) {
27        $this->account_protection = $account_protection ?? Account_Protection::instance();
28    }
29
30    /**
31     * Get account protection settings.
32     *
33     * @return array
34     */
35    public function get() {
36        $settings = array(
37            'isEnabled'                    => $this->account_protection->is_enabled(),
38            'isSupported'                  => $this->account_protection->is_supported_environment(),
39            'hasUnsupportedJetpackVersion' => $this->account_protection->has_unsupported_jetpack_version(),
40        );
41
42        return $settings;
43    }
44}