| 1 |
<?php |
| 2 |
/** |
| 3 |
* SSL Checker class |
| 4 |
* |
| 5 |
* @package micropackage/requirements |
| 6 |
*/ |
| 7 |
|
| 8 |
namespace Micropackage\Requirements\Checker; |
| 9 |
|
| 10 |
use Micropackage\Requirements\Abstracts; |
| 11 |
use Micropackage\Requirements\Requirements; |
| 12 |
|
| 13 |
/** |
| 14 |
* SSL Checker class |
| 15 |
*/ |
| 16 |
class SSL extends Abstracts\Checker { |
| 17 |
|
| 18 |
/** |
| 19 |
* Checker name |
| 20 |
* |
| 21 |
* @var string |
| 22 |
*/ |
| 23 |
protected $name = 'ssl'; |
| 24 |
|
| 25 |
/** |
| 26 |
* Checks if the requirement is met |
| 27 |
* |
| 28 |
* @since 1.1.0 |
| 29 |
* @throws \Exception When provided value is not a string or numeric. |
| 30 |
* @param string $enabled If SSL should be enabled or disabled. |
| 31 |
* @return void |
| 32 |
*/ |
| 33 |
public function check( $enabled ) { |
| 34 |
|
| 35 |
if ( ! is_bool( $enabled ) ) { |
| 36 |
throw new \Exception( 'SSL Check requires bool parameter' ); |
| 37 |
} |
| 38 |
|
| 39 |
if ( $enabled && ! is_ssl() ) { |
| 40 |
$this->add_error( __( 'SSL is required', Requirements::$textdomain ) ); |
| 41 |
} |
| 42 |
|
| 43 |
if ( ! $enabled && is_ssl() ) { |
| 44 |
$this->add_error( __( 'SSL is superfluous', Requirements::$textdomain ) ); |
| 45 |
} |
| 46 |
|
| 47 |
} |
| 48 |
|
| 49 |
} |
| 50 |
|