Your IP : 3.22.208.99


Current Path : /home/ephorei/www/wp-includes/images/media/q2m9hb/
Upload File :
Current File : /home/ephorei/www/wp-includes/images/media/q2m9hb/Traits.tar

RESTResponseError.php000064400000001602150061521520010557 0ustar00<?php

namespace WPConsole\Traits;

use Exception;
use WPConsole\Exceptions\WPConsoleException;
use WP_Error;

trait RESTResponseError {

    /**
     * Send REST error response
     *
     * @since 1.3.0
     *
     * @param \Exception $e
     * @param string     $default_message
     *
     * @return \WP_Error
     */
    protected function send_response_error( Exception $e, $default_message = '' ) {
        if ( $e instanceof WPConsoleException ) {
            return new WP_Error(
                $e->get_error_code(),
                $e->get_message(),
                [ 'status' => $e->get_status_code() ]
            );
        }

        $default_message = $default_message ? $default_message : __( 'Something went wrong', 'wp-console' );

        return new WP_Error(
            'something_went_wrong',
            $default_message,
            [ 'status' => 422 ]
        );
    }
}
Singleton.php000064400000001245150061521520007216 0ustar00<?php

namespace WPConsole\Traits;

/**
 * Singleton Trait
 *
 * @since 1.0.0
 */
trait Singleton {

    /**
     * Singleton class instance holder
     *
     * @since 1.0.0
     *
     * @var object
     */
    private static $instance;

    /**
     * Make a class instance
     *
     * @since 1.0.0
     *
     * @return object
     */
    public static function instance() {
        if ( ! isset( self::$instance ) && ! ( self::$instance instanceof self ) ) {
            self::$instance = new self();

            if ( method_exists( self::$instance, 'boot' ) ) {
                self::$instance->boot();
            }
        }

        return self::$instance;
    }
}
SingletonLoader.php000064400000001732150061526730010356 0ustar00<?php
/**
 * SingletonLoader.
 * php version 5.6
 *
 * @category SingletonLoader
 * @package  SureTriggers
 * @author   BSF <username@example.com>
 * @license  https://www.gnu.org/licenses/gpl-3.0.html GPLv3
 * @link     https://www.brainstormforce.com/
 * @since    1.0.0
 */

namespace SureTriggers\Traits;

/**
 * Trait SingletonLoader
 *
 * @template SingletonLoader
 *
 * @category SingletonLoader
 * @package SureTriggers\Traits
 * @author   BSF <username@example.com>
 * @license  https://www.gnu.org/licenses/gpl-3.0.html GPLv3
 * @link     https://www.brainstormforce.com/
 * @since    1.0.0
 */
trait SingletonLoader {

	/**
	 * Instance
	 *
	 * @access public
	 * @var    null|object
	 * @since  1.0.0
	 */

	public static $_instance;

	/**
	 * Initiator
	 *
	 * @return SingletonLoader|object|null
	 *
	 * @since 1.0.0
	 */
	public static function get_instance() {
		if ( empty( self::$_instance ) ) {
			self::$_instance = new self();
		}

		return self::$_instance;
	}

}