Sindbad~EG File Manager

Current Path : /home/nicedoo/www/wp-content/plugins/tier-pricing-table/src/Core/
Upload File :
Current File : /home/nicedoo/www/wp-content/plugins/tier-pricing-table/src/Core/ServiceContainer.php

<?php namespace TierPricingTable\Core;

use Exception;
use TierPricingTable\Settings\Settings;

class ServiceContainer {
	
	private $services = array();
	
	private static $instance;
	
	private function __construct() {}
	
	public static function getInstance(): self {
		if ( is_null( self::$instance ) ) {
			self::$instance = new self();
		}
		
		return self::$instance;
	}
	
	public function add( $name, $instance ) {
		
		$instance = apply_filters( 'tiered_pricing_table/container/service_instance', $instance, $name );
		
		$this->services[ $name ] = $instance;
	}
	
	/**
	 * Get service
	 *
	 * @param $name
	 *
	 * @return mixed
	 * @throws Exception
	 */
	public function get( $name ) {
		if ( ! empty( $this->services[ $name ] ) ) {
			return $this->services[ $name ];
		}
		
		throw new Exception( 'Undefined service' );
	}
	
	/**
	 * Get fileManager
	 *
	 * @return FileManager
	 */
	public function getFileManager() {
		try {
			return $this->get( 'fileManager' );
		} catch ( Exception $e ) {
			return null;
		}
	}
	
	/**
	 * Get Settings
	 *
	 * @return Settings
	 */
	public function getSettings() {
		try {
			return $this->get( 'settings' );
		} catch ( Exception $e ) {
			return null;
		}
	}
	
	/**
	 * Get AdminNotifier
	 *
	 * @return AdminNotifier
	 */
	public function getAdminNotifier() {
		try {
			return $this->get( 'adminNotifier' );
		} catch ( Exception $e ) {
			return null;
		}
	}
	
	/**
	 * Get Cache
	 *
	 * @return Cache
	 */
	public function getCache() {
		try {
			return $this->get( 'cache' );
		} catch ( Exception $e ) {
			return null;
		}
	}
}

Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists