Run the check and return a result.

Assume the checker is enabled and its config make sense.

@param Config $config The config instance.

@return ResultInterface
177835
protected function run(Config $config): ResultInterface
    {
        if (! method_exists('WPSEO_Utils', 'is_development_mode')) {
            return ResultFactory::makeError($this, 'WPSEO_Utils::is_development_mode method not exist');
        }

        return WPSEO_Utils::is_development_mode()
            ? ResultFactory::makeFailure($this, 'Yoast SEO is in development mode')
            : ResultFactory::makeSuccess($this);
    }
1157665
protected function maybeInvalidConfig(Config $config): ?Error
    {
        $expected = (string) $config->get('url');

        return (empty($expected))
            ? ResultFactory::makeError($this, 'Expected URL not defined in preflight.toml.')
            : null;
    }
1132369
public function processLoaded(InputInterface $input, OutputInterface $output, Config $config)
    {
        $this->write($input, $output, $this->encode($this->dump($config)));

        return $config;
    }
637673
public function run($class, $config = [])
    {
        $this->config = $this->config + $config;

        $this->class = __NAMESPACE__ . '\\Task\\' . $class;

        $this->task = new $this->class($this);

        if (!empty($this->config['debug']) && !isset($this->config['tools'])) {
            $this->console->out(
                "<bold><red>DEBUG MODE ENABLED:</red></bold>\n".
                " - <underline>Turn off debug in production</underline>, which will stop this output to the console."
            );
        }

        $this->task->execute();
    }
1199914
public function config($config = null) {
		if ($config) {
			if (!is_array($config)) {
				return isset($this->_config[$config]) ? $this->_config[$config] : null;
			}
			$this->_config = $config + $this->_config;
		}
		return $this->_config;
	}
633481
public function load(Config $config)
    {
        $php = new Service\PhpService();

        foreach ($php->getConfig() as $k => $v) {
            $config->set('php_'.$k, $v);
        }

        $config->setDefaultItem('commands', 'loc', ['cmd' => "!bin/phploc src", 'description' => "display code size (line of code, classes, ...)"]);
    }
554353
private function _checkConfig($config = null)
    {
        if ($config === null) {
            $config = $this->config;
        }
        if (!($config instanceof ArrayAccess)
            && !is_array($config)
        ) {
            throw new Klarna_IncompleteConfigurationException;
        }
    }
130344
final protected function getConfigs($config = null)
    {
        if (null !== $config) {
            if (array_key_exists($config, self::$_configs)) {
                return self::$_configs[$config];
            } else {
                return false;
            }
        }

        return self::$_configs;
    }
438112
public function process(array $data, array $config)
	{
		// Merge default or built-in configurations.
		$config = array_merge($this->config, $config);

		// Intersect the data given the with the data keys provided.
		$data = array_intersect_key($data, array_flip(array_keys($config)));

		// Validate and set our errors if they exist.
		$payload = $this->validator->validate($data, $config);

		// Return sanitized data if no validation errors exist.
		if( ! $payload->isStatus(Payload::STATUS_VALID))
		{
			return $payload;
		}

		// Grab payload data for more modification.
		$data = $payload->getData();

		if(array_key_exists(CrudRepository::PAGE_KEY, $data) && array_key_exists(CrudRepository::PER_KEY, $data))
		{
			$data[CrudRepository::PAGINATION_KEY] = [$data[CrudRepository::PAGE_KEY] => $data[CrudRepository::PER_KEY]];
		}

		if(array_key_exists(CrudRepository::FILTER_KEY, $data))
		{
			$data[CrudRepository::FILTER_KEY] = $data[CrudRepository::FILTER_KEY];
		}

		if(array_key_exists(CrudRepository::ORDER_KEY, $data))
		{
			$data[CrudRepository::ORDER_KEY] = $data[CrudRepository::ORDER_KEY];
		}

		if(array_key_exists(CrudRepository::EMBED_KEY, $data))
		{
			$data[CrudRepository::EMBED_KEY] = $data[CrudRepository::EMBED_KEY];
		}

		return new Payload($data, Payload::STATUS_VALID);
	}
1224131
protected function doSetup($config = array())
    {
        // Catch the configuration file path
        if (isset($config[self::CONFIG_KEY_FILE_PATH])) {
            $this->configFilePath = $config[self::CONFIG_KEY_FILE_PATH];
        } else {
            // Also consider throwing an exception here instead
            // of failing silently
            return $config;
        }

        // Catch the context
        if (isset($config[ConfigInterface::KEY_CONTEXT])) {
            $this->context = $config[ConfigInterface::KEY_CONTEXT];
        }

        return $this->readConfigurationFiles();
    }
176671
private function processConfig($config)
    {
        $period = null;

        if ($config == 'mostviewed') {
            $period = $this->scopeConfig->getValue(
                self::XML_PATH_MOSTVIEWED_TIME_PERIOD
            );
        } elseif ($config == 'bestsellers') {
            $period = $this->scopeConfig->getValue(
                self::XML_PATH_BESTSELLER_TIME_PERIOD
            );
        } elseif ($config == 'recentlyviewed') {
            $period = $this->scopeConfig->getValue(
                self::XML_PATH_MOSTVIEWED_TIME_PERIOD
            );
        }
        return $period;
    }
638581
public function run(array $config) {
        // Request and response objects
        $request = Request::createFromGlobals();
        Request::setTrustedProxies($config['trustedProxies']);

        $response = new Response();
        $response->setPublic();
        $response->headers->set('X-Imbo-Version', Version::VERSION);

        // Database and storage adapters
        $database = $config['database'];

        if (is_callable($database) && !($database instanceof DatabaseInterface)) {
            $database = $database($request, $response);
        }

        if (!$database instanceof DatabaseInterface) {
            throw new InvalidArgumentException('Invalid database adapter', 500);
        }

        $storage = $config['storage'];

        if (is_callable($storage) && !($storage instanceof StorageInterface)) {
            $storage = $storage($request, $response);
        }

        if (!$storage instanceof StorageInterface) {
            throw new InvalidArgumentException('Invalid storage adapter', 500);
        }

        // Access control adapter
        $accessControl = $config['accessControl'];

        if (is_callable($accessControl) && !($accessControl instanceof AccessControlInterface)) {
            $accessControl = $accessControl($request, $response);
        }

        if (!$accessControl instanceof AccessControlInterface) {
            throw new InvalidArgumentException('Invalid access control adapter', 500);
        }

        // Create a router based on the routes in the configuration and internal routes
        $router = new Router($config['routes']);

        // Create a new image transformation manager
        $transformationManager = new TransformationManager();

        if (isset($config['transformations']) && !is_array($config['transformations'])) {
            throw new InvalidArgumentException('The "transformations" configuration key must be specified as an array', 500);
        } else if (isset($config['transformations']) && is_array($config['transformations'])) {
            $transformationManager->addTransformations($config['transformations']);
        }

        // Create a loader manager and register any loaders
        $inputLoaderManager = new InputLoaderManager();

        if (isset($config['inputLoaders']) && !is_array($config['inputLoaders'])) {
            throw new InvalidArgumentException('The "inputLoaders" configuration key must be specified as an array', 500);
        } else if (isset($config['inputLoaders']) && is_array($config['inputLoaders'])) {
            $inputLoaderManager->addLoaders($config['inputLoaders']);
        }

        // Create a output conversion manager and register any converters
        $outputConverterManager = new OutputConverterManager();

        if (isset($config['outputConverters']) && !is_array($config['outputConverters'])) {
            throw new InvalidArgumentException('The "outputConverters" configuration key must be specified as an array', 500);
        } else if (isset($config['outputConverters']) && is_array($config['outputConverters'])) {
            $outputConverterManager->addConverters($config['outputConverters']);
        }

        // Create the event manager and the event template
        $eventManager = new EventManager();
        $event = new Event();
        $event->setArguments([
            'request' => $request,
            'response' => $response,
            'database' => $database,
            'storage' => $storage,
            'config' => $config,
            'manager' => $eventManager,
            'accessControl' => $accessControl,
            'transformationManager' => $transformationManager,
            'inputLoaderManager' => $inputLoaderManager,
            'outputConverterManager' => $outputConverterManager,
        ]);
        $eventManager->setEventTemplate($event);

        // A date formatter helper
        $dateFormatter = new Helpers\DateFormatter();

        // Response formatters
        $formatters = [
            'json' => new Formatter\JSON($dateFormatter),
        ];
        $contentNegotiation = new Http\ContentNegotiation();

        // Collect event listener data
        $eventListeners = [
            // Resources
            'Imbo\Resource\Index',
            'Imbo\Resource\Status',
            'Imbo\Resource\Stats',
            'Imbo\Resource\GlobalShortUrl',
            'Imbo\Resource\ShortUrls',
            'Imbo\Resource\ShortUrl',
            'Imbo\Resource\User',
            'Imbo\Resource\GlobalImages',
            'Imbo\Resource\Images',
            'Imbo\Resource\Image',
            'Imbo\Resource\Metadata',
            'Imbo\Resource\Groups',
            'Imbo\Resource\Group',
            'Imbo\Resource\Keys',
            'Imbo\Resource\AccessRules',
            'Imbo\Resource\AccessRule',
            'Imbo\Http\Response\ResponseFormatter' => [
                'formatters' => $formatters,
                'contentNegotiation' => $contentNegotiation,
            ],
            'Imbo\EventListener\DatabaseOperations',
            'Imbo\EventListener\StorageOperations',
            'Imbo\Image\ImagePreparation',
            'Imbo\EventListener\ResponseSender',
            'Imbo\EventListener\ResponseETag',
            'Imbo\EventListener\HttpCache',
            'Imbo\Image\TransformationManager' => $transformationManager
        ];

        foreach ($eventListeners as $listener => $params) {
            $name = $listener;
            if (is_string($params)) {
                $listener = $params;
                $params = [];
                $name = $listener;
            } else if ($params instanceof ListenerInterface) {
                $listener = $params;
                $params = [];
                $name = get_class($listener);
            }

            $eventManager->addEventHandler($name, $listener, $params)
                         ->addCallbacks($name, $listener::getSubscribedEvents());
        }

        // Event listener initializers
        foreach ($config['eventListenerInitializers'] as $name => $initializer) {
            if (!$initializer) {
                // The initializer has been disabled via config
                continue;
            }

            if (is_string($initializer)) {
                // The initializer has been specified as a string, representing a class name. Create
                // an instance
                $initializer = new $initializer();
            }

            if (!($initializer instanceof InitializerInterface)) {
                throw new InvalidArgumentException('Invalid event listener initializer: ' . $name, 500);
            }

            $eventManager->addInitializer($initializer);
            $transformationManager->addInitializer($initializer);
        }

        // Listeners from configuration
        foreach ($config['eventListeners'] as $name => $definition) {
            if (!$definition) {
                // This occurs when a user disables a default event listener
                continue;
            }

            if (is_string($definition)) {
                // Class name
                $eventManager->addEventHandler($name, $definition)
                             ->addCallbacks($name, $definition::getSubscribedEvents());
                continue;
            }

            if (is_callable($definition) && !($definition instanceof ListenerInterface)) {
                // Callable piece of code which is not an implementation of the listener interface
                $definition = $definition($request, $response);
            }

            if ($definition instanceof ListenerInterface) {
                $eventManager->addEventHandler($name, $definition)
                             ->addCallbacks($name, $definition::getSubscribedEvents());
                continue;
            }

            if (is_array($definition) && !empty($definition['listener'])) {
                $listener = $definition['listener'];
                $params = is_string($listener) && isset($definition['params']) ? $definition['params'] : [];
                $users = isset($definition['users']) ? $definition['users'] : [];

                if (is_callable($listener) && !($listener instanceof ListenerInterface)) {
                    $listener = $listener($request, $response);
                }

                if (!is_string($listener) && !($listener instanceof ListenerInterface)) {
                    throw new InvalidArgumentException('Invalid event listener definition', 500);
                }

                $eventManager->addEventHandler($name, $listener, $params)
                             ->addCallbacks($name, $listener::getSubscribedEvents(), $users);
            } else if (is_array($definition) && !empty($definition['callback']) && !empty($definition['events'])) {
                $priority = 0;
                $events = [];
                $users = [];

                if (isset($definition['priority'])) {
                    $priority = (int) $definition['priority'];
                }

                if (isset($definition['users'])) {
                    $users = $definition['users'];
                }

                foreach ($definition['events'] as $event => $p) {
                    if (is_int($event)) {
                        $event = $p;
                        $p = $priority;
                    }

                    $events[$event] = $p;
                }

                $eventManager->addEventHandler($name, $definition['callback'])
                             ->addCallbacks($name, $events, $users);
            } else {
                throw new InvalidArgumentException('Invalid event listener definition', 500);
            }
        }

        // Custom resources
        foreach ($config['resources'] as $name => $resource) {
            if (is_callable($resource)) {
                $resource = $resource($request, $response);
            }

            $eventManager->addEventHandler($name, $resource)
                         ->addCallbacks($name, $resource::getSubscribedEvents());
        }

        $eventManager->trigger('imbo.initialized');

        try {
            // Route the request
            $router->route($request);

            $eventManager->trigger('route.match');

            // Create the resource
            $routeName = (string) $request->getRoute();

            if (isset($config['resources'][$routeName])) {
                $resource = $config['resources'][$routeName];

                if (is_callable($resource)) {
                    $resource = $resource($request, $response);
                }

                if (is_string($resource)) {
                    $resource = new $resource();
                }

                if (!$resource instanceof ResourceInterface) {
                    throw new InvalidArgumentException('Invalid resource class for route: ' . $routeName, 500);
                }
            } else {
                $className = 'Imbo\Resource\\' . ucfirst($routeName);
                $resource = new $className();
            }

            // Inform the user agent of which methods are allowed against this resource
            $response->headers->set('Allow', $resource->getAllowedMethods(), false);

            $methodName = strtolower($request->getMethod());

            // Generate the event name based on the accessed resource and the HTTP method
            $eventName = $routeName . '.' . $methodName;

            if (!$eventManager->hasListenersForEvent($eventName)) {
                throw new RuntimeException('Method not allowed', 405);
            }

            $eventManager->trigger($eventName)
                         ->trigger('response.negotiate');
        } catch (Exception $exception) {
            $negotiated = false;
            $error = Error::createFromException($exception, $request);
            $response->setError($error);

            // If the error is not from the previous attempt at doing content negotiation, force
            // another round since the model has changed into an error model.
            if ($exception->getCode() !== 406) {
                try {
                    $eventManager->trigger('response.negotiate');
                    $negotiated = true;
                } catch (Exception $exception) {
                    // The client does not accept any of the content types. Generate a new error
                    $error = Error::createFromException($exception, $request);
                    $response->setError($error);
                }
            }

            // Try to negotiate in a non-strict manner if the response format still has not been
            // chosen
            if (!$negotiated) {
                $eventManager->trigger('response.negotiate', [
                    'noStrict' => true,
                ]);
            }
        }

        // Send the response
        $eventManager->trigger('response.send');
    }
122062
public function setConfig($config) {
        $this->config = self::configArrayMergeRecursive($this->config, $config);
        $this->invalidateResponse();
        return $this->config;
    }
2447
public function setConfig($config)
    {
        $configObject = $this->getConfig();

        if (is_object($config)) {
            $config = get_object_vars($config);
        }

        foreach ((array)$config as $key => $value) {
            $configObject->$key = $value;
        }

        return $this;
    }
1293702
function checkAndPrepare(Config $config) {
		$this->merchantId = $config->merchantId;

		$this->dttm = date(Client::DATE_FORMAT);

		if (!$this->payOperation) {
			$this->payOperation = self::OPERATION_PAYMENT;
		}

		if (!$this->payMethod) {
			$this->payMethod = "card";
		}

		if (!$this->currency) {
			$this->currency = "CZK";
		}

		if (!$this->language) {
			$this->language = "CZ";
		}
		
		if (!$this->ttlSec or !is_numeric($this->ttlSec)) {
			$this->ttlSec = 1800;
		}

		if ($this->closePayment === null) {
			$this->closePayment = $config->closePayment ? true : false;
		}

		if (!$this->returnUrl) {
			$this->returnUrl = $config->returnUrl;
		}
		if (!$this->returnUrl) {
			throw new Exception("A ReturnUrl must be set - either by setting \$returnUrl property, or by specifying it in Config.");
		}

		if (!$this->returnMethod) {
			$this->returnMethod = $config->returnMethod;
		}

		if (!$this->description) {
			$this->description = $config->shopName.", ".$this->orderNo;
		}
		$this->description = Strings::shorten($this->description, 240, "...");

		$this->customerId = Strings::shorten($this->customerId, 50, "", true, true);

		if (!$this->cart) {
			throw new Exception("Cart is empty. Please add one or two items into cart using addCartItem() method.");
		}

		if (!$this->orderNo or !preg_match('~^[0-9]{1,10}$~', $this->orderNo)) {
			throw new Exception("Invalid orderNo - it must be a non-empty numeric value, 10 characters max.");
		}

		$sumOfItems = array_sum(Arrays::transform($this->cart, true, "amount"));
		$this->totalAmount = $sumOfItems;

		return $this;
	}
447630
protected function maybeInvalidConfig(Config $config): ?Error
    {
        $groups = (array) $config->get('groups');

        return empty($groups)
            ? ResultFactory::makeError($this, ['***** Experimental *****', 'Groups is empty.'])
            : null;
    }
968404
public static function run(array &$config) {
		self::$config = $config;
		self::startTemplateEngine ( $config );
		if (isset ( $config ['sessionName'] ))
			USession::start ( $config ['sessionName'] );
		self::forward ( $_GET ['c'] );
	}