PluginProbe
MultiSafepay plugin for WooCommerce / trunk
MultiSafepay plugin for WooCommerce vtrunk
6.11.1 6.12.0 6.13.0 6.2.0 6.2.1 6.3.0 6.3.1 6.4.0 6.4.1 6.4.2 6.4.3 6.5.0 6.5.1 6.6.0 6.6.1 6.6.2 6.7.0 6.7.1 6.7.2 6.7.3 6.8.0 6.8.1 6.8.2 6.8.3 6.9.0 All 84 releases
multisafepay / src / Utils / DependencyChecker.php

DependencyChecker.php in MultiSafepay plugin for WooCommerce trunk, at src/Utils/DependencyChecker.php

53 lines 1.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php declare(strict_types=1);
2
3 namespace MultiSafepay\WooCommerce\Utils;
4
5 use MultiSafepay\WooCommerce\Exceptions\MissingDependencyException;
6
7 /**
8 * Fired on bootstrap plugin file.
9 * This class defines all code necessary to check if there is a dependency missing to make the plugin work
10 */
11 class DependencyChecker {
12
13 const REQUIRED_PLUGINS = array(
14 'WooCommerce' => 'woocommerce/woocommerce.php',
15 );
16
17 /**
18 * Check if there is a dependency missing to make the plugin work
19 *
20 * @throws MissingDependencyException
21 * @return void
22 */
23 public function check(): void {
24 $missing_plugins = $this->get_missing_plugins_list();
25 if ( ! empty( $missing_plugins ) ) {
26 throw new MissingDependencyException( $missing_plugins );
27 }
28 }
29
30 /**
31 * Return the keys of all missing plugins
32 *
33 * @return array
34 */
35 private function get_missing_plugins_list(): array {
36 return array_keys( array_filter( self::REQUIRED_PLUGINS, array( $this, 'is_plugin_inactive' ) ) );
37 }
38
39 /**
40 * Check if a certain plugin is inactive
41 *
42 * @param string $plugin_path
43 * @return boolean
44 */
45 private function is_plugin_inactive( string $plugin_path ): bool {
46 if ( ! is_plugin_active( $plugin_path ) ) {
47 return true;
48 }
49
50 return false;
51 }
52 }
53