MOON
Server: Apache
System: Linux nserver.cafsindia.com 4.18.0-553.104.1.lve.el8.x86_64 #1 SMP Tue Feb 10 20:07:30 UTC 2026 x86_64
User: cafsindia (1002)
PHP: 8.2.30
Disabled: NONE
Upload Files
File: //proc/self/root/home/cafsindia/public_html/wp-content/plugins/imageseo/src/Context.php
<?php

namespace ImageSeoWP;

if (! defined('ABSPATH')) {
    exit;
}

use ImageSeoWP\Bootstrap;

/**
 * Only use for get one context
 */
abstract class Context
{

    /**
     * @static
     * @since 1.0
     * @var Bootstrap|null
     */
    protected static $context;

    /**
     * Create context if not exist
     *
     * @static
     * @since 1.0
     * @return void
     */
    public static function getContext()
    {
        if (null !== self::$context) {
            return self::$context;
        }

        self::$context = new Bootstrap();

        self::getClasses(__DIR__ . '/Services', 'services', 'Services\\');
        self::getClasses(__DIR__ . '/Actions', 'actions', 'Actions\\');



        return self::$context;
    }

    /**
     * @static
     * @param string $path
     * @param string $type
     * @param string $namespace
     * @return void
     */
    public static function getClasses($path, $type, $namespace = '')
    {
        $files      = array_diff(scandir($path), [ '..', '.' ]);
        foreach ($files as $filename) {
            $pathCheck = $path . '/' . $filename;
            if (is_dir($pathCheck)) {
                self::getClasses($pathCheck, $type, $namespace . $filename . '\\');
                continue;
            }

            $data = '\\ImageSeoWP\\' . $namespace . str_replace('.php', '', $filename);

            switch ($type) {
                case 'services':
                    self::$context->setService($data);
                    break;
                case 'actions':
                    self::$context->setAction($data);
                    break;
            }
        }
    }
}