Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
14 / 14 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
| Plugin_Updater | |
100.00% |
14 / 14 |
|
100.00% |
1 / 1 |
4 | |
100.00% |
1 / 1 |
| get_instance | |
100.00% |
14 / 14 |
|
100.00% |
1 / 1 |
4 | |||
| 1 | <?php |
| 2 | /** |
| 3 | * @package brianhenryie/bh-wp-plugin-updater |
| 4 | */ |
| 5 | |
| 6 | namespace BrianHenryIE\WP_Plugin_Updater; |
| 7 | |
| 8 | use Psr\Log\LoggerInterface; |
| 9 | use Psr\Log\NullLogger; |
| 10 | |
| 11 | class Plugin_Updater { |
| 12 | |
| 13 | protected static API_Interface $instance; |
| 14 | |
| 15 | public static function get_instance( ?Settings_Interface $settings = null, ?LoggerInterface $logger = null ): API_Interface { |
| 16 | |
| 17 | if ( ! isset( self::$instance ) && is_null( $settings ) ) { |
| 18 | throw new \Exception( 'Settings must be provided on first call.' ); |
| 19 | } |
| 20 | |
| 21 | $logger = $logger ?? new NullLogger(); |
| 22 | |
| 23 | if ( ! isset( self::$instance ) ) { |
| 24 | self::$instance = new API( |
| 25 | $settings, |
| 26 | $logger |
| 27 | ); |
| 28 | new Actions( |
| 29 | self::$instance, |
| 30 | $settings, |
| 31 | $logger |
| 32 | ); |
| 33 | } |
| 34 | |
| 35 | return self::$instance; |
| 36 | } |
| 37 | } |