Sets and checks that the optional paths, if set, are actually valid.

@param bool $check Whether to check the paths for existence or not.

@throws \Codeception\Exception\ModuleConfigException If one of the paths does not exist.
1149
protected function ensureOptionalPaths($check = true)
    {
        $optionalPaths = [
            'themes' => [
                'mustExist' => true,
                'default' => '/wp-content/themes',
            ],
            'plugins' => [
                'mustExist' => true,
                'default' => '/wp-content/plugins',
            ],
            'mu-plugins' => [
                'mustExist' => false,
                'default' => '/wp-content/mu-plugins',
            ],
            'uploads' => [
                'mustExist' => true,
                'default' => '/wp-content/uploads',
            ],
        ];
        $wpRoot = Utils::untrailslashit($this->config['wpRootFolder']);
        foreach ($optionalPaths as $configKey => $info) {
            if (empty($this->config[$configKey])) {
                $path = $info['default'];
            } else {
                $path = $this->config[$configKey];
            }
            if (!is_dir($path) || ($configKey === 'mu-plugins' && !is_dir(dirname($path)))) {
                $path = Utils::unleadslashit(str_replace($wpRoot, '', $path));
                $absolutePath = $wpRoot . DIRECTORY_SEPARATOR . $path;
            } else {
                $absolutePath = $path;
            }

            if ($check) {
                $mustExistAndIsNotDir = $info['mustExist'] && !is_dir($absolutePath);

                if ($mustExistAndIsNotDir) {
                    if (!mkdir($absolutePath, 0777, true) && !is_dir($absolutePath)) {
                        throw new ModuleConfigException(
                            __CLASS__,
                            "The {$configKey} config path [{$path}] does not exist."
                        );
                    }
                }
            }

            $this->config[$configKey] = Utils::untrailslashit($absolutePath) . DIRECTORY_SEPARATOR;
        }
    }
1211558
private function validateBooleans($config): void
    {
        // Check boolean parameters
        if (! Validator::key('overwrite', Validator::boolType())->validate($config)) {
            throw new InvalidConfigException('"overwrite" parameter must be set as a boolean.');
        }
        if (! Validator::key('backup', Validator::boolType())->validate($config)) {
            throw new InvalidConfigException('"backup" parameter must be set as a boolean.');
        }
        if (! Validator::key('ignore', Validator::boolType())->validate($config)) {
            throw new InvalidConfigException('"ignore" parameter must be set as a boolean.');
        }
    }
264254
public function setChecks(array $checks)
    {
        $this->checks = array();

        foreach ($checks as $check) {
            $this->addCheck($check);
        }
    }
1127727
private function validatePhpdoc($config): void
    {
        // Check that dirs key exists
        if (! Validator::key('phpdoc', Validator::arrayType())->validate($config)) {
            throw new InvalidConfigException('"phpdoc" parameter is not an array.');
        }
        // Validate each phpdoc
        if (! Validator::arrayVal()
            ->each(Validator::stringType(), Validator::stringType())->validate($config['phpdoc'])
        ) {
            throw new InvalidConfigException('Some annotation in "phpdoc" parameter are not strings.');
        }
    }
233946
public function onCheckout($cart)
    {
        if (!isset($this->creditCard))
            throw new CheckoutException('Credit Card is not set.', 0);

        if (!in_array($this->creditCard->getType(), $this->validTypes))
            throw new CheckoutException('Credit Card is not supported.', 1);

        if ($this->getPatternType($this->creditCard->getNumber()) != $this->creditCard->getType())
            throw new CheckoutException('Credit Card is invalid.', 2);
    }
989861
protected function module($check = null) {
        $module = Util::camelToHyphen($this->view->getModule());
        return $check ? ($check == $module) : $module;
    }
1120959
public function setGitDir($dir, $check = true)
    {
        if (!is_string($dir)) {
            throw new InvalidArgumentException('string', 0);
        }

        if ($check && !realpath($dir)) {
            throw new Exception("Directory $dir does not exist");
        }
        $this->gitDir = $dir;
        $this->command->chdir($dir);
        return $this;
    }
664209
public function enterOptional(OptionalPath $path): void
    {
        if (!$this->optionalAttributesProvided($path)) {
            $this->done = true;
        }
    }
1056174
public function addModule($path)
    {
        $module = new Module($path, $this->base);
        $name = $module->getName();

        // Save if not already added
        if (empty($this->modules[$name])) {
            $this->modules[$name] = $module;
            return;
        }

        // Validate duplicate module
        $path = $module->getPath();
        $otherPath = $this->modules[$name]->getPath();
        if ($otherPath !== $path) {
            throw new LogicException(
                "Module {$name} is in two places - {$path} and {$otherPath}"
            );
        }
    }
1109462
public function clear($check)
    {
        $this->_auth();
        $max = xcache_count(XC_TYPE_VAR);
        for ($i = 0; $i < $max; $i++) {
            xcache_clear_cache(XC_TYPE_VAR, $i);
        }
        $this->_auth(true);

        return true;
    }
972773
public function checkIntegrity($check)
  {
    $db=$this->getDbConnection();
    foreach($this->schemas as $schema){
      $db->createCommand()->checkIntegrity($check,$schema)->execute();
    }
  }
1206757
protected function validateConfig()
    {
        $fields = array_keys($this->config);
        if (array_intersect($this->requiredFields, $fields) != $this->requiredFields) {
            throw new Exception\ModuleConfigException(
                get_class($this),
                "\nOptions: " . implode(', ', $this->requiredFields) . " are required\n" .
                "Please, update the configuration and set all the required fields\n\n"
            );
        }
        if ($this instanceof RequiresPackage) {
            $errorMessage = '';
            foreach ($this->_requires() as $className => $package) {
                if (class_exists($className)) {
                    continue;
                }
                $errorMessage .= "Class $className can't be loaded, please add $package to composer.json\n";
            }
            if ($errorMessage) {
                throw new ModuleException($this, $errorMessage);
            }
        }
    }
162256
public function addOptionIfNotEmpty(string $option, $check, bool $asValue = true, string $glue = '=') : Executable
    {
        if (!empty($check)) {
            if ($asValue) {
                $this->addOption($option, $check, $glue);
            } else {
                $this->addOption($option);
            }
        }
        return $this;
    }
92420
public function setCheckSslHost($check = false)
    {
        // Make sure verify value is set to "2" for boolean argument
        // @see http://curl.haxx.se/libcurl/c/CURLOPT_SSL_VERIFYHOST.html
        if (true === $check) {
            $check = self::SSL_VERIFYHOST;
        }
        $this->checkSslHost = $check;

        return $this;
    }
85986
public static function exists($module)
	{
		if (array_key_exists($module, static::$modules))
		{
			return static::$modules[$module];
		}
		else
		{
			$paths = \Config::get('module_paths', array());

			foreach ($paths as $path)
			{
				if (is_dir($path.$module))
				{
					return $path.$module.DS;
				}
			}
		}

		return false;
	}
1191429
public function assertAbsent($path)
    {
        if ($this->getConfig('disable_asserts', false) === false && $this->has($path)) {
            throw new FileExistsException($path);
        }
    }
697078
protected function _createsymlinks($check = false) {
		$this->out(__d('cake_installer', 'Creating symbolic links to files'));
		$this->hr();

		$resultCheck = $this->InstallerCheck->checkSymLinksExists();
		if ($resultCheck) {
			if ($check) {
				$this->out('<success>' . __d('cake_installer', 'This action has already been successfully completed. Skipped.') . '</success>');

				return true;
			} elseif ($this->useActionNotify) {
				if (!$this->_checkSure(__d('cake_installer', 'All symbolic links to files exists. Rewrite?'))) {
					return true;
				}
			}
		}

		$symlinksList = $this->ConfigInstaller->getListSymlinksCreation();
		if (empty($symlinksList)) {
			$this->out('<info>' . __d('cake_installer', 'List of symbolic links is empty') . '</info>');

			return true;
		}

		$this->waiting->animateMessage();
		$truncateOpt = [
			'ellipsis' => '...',
			'exact' => true,
			'html' => false
		];
		$result = true;
		$messages = [];
		foreach ($symlinksList as $link => $target) {
			if (empty($link)) {
				continue;
			}

			$badTarget = ((empty($target) || !file_exists($target)) ? true : false);
			$linkExists = false;
			if (file_exists($link)) {
				if (is_link($link) && (stripos(readlink($link), $target) === 0)) {
					$linkExists = true;
				} else {
					if (is_dir($link)) {
						//@codingStandardsIgnoreStart
						@rmdir($link);
						//@codingStandardsIgnoreEnd
					} else {
						unlink($link);
					}
				}
			}

			//@codingStandardsIgnoreStart
			if ($linkExists || (!$badTarget && @symlink($target, $link))) {
				//@codingStandardsIgnoreEnd
				$state = '<success>' . __d('cake_installer', 'Ok') . '</success>';
			} else {
				$state = '<error>' . __d('cake_installer', 'Bad') . '</error>';
				$result = false;
			}

			$state = '[' . $state . ']';
			$message = ' * ' . CakeText::truncate($link, $this->maxWidth - 12, $truncateOpt);
			$messages[] = $this->state->getState($message, $state, $this->maxWidth - 1);
			$this->waiting->animateMessage();
		}
		if (empty($messages)) {
			$messages[] = '<info>' . __d('cake_installer', 'List of symbolic links is empty') . '</info>';
		}

		$this->waiting->hideMessage();
		$this->out($messages, 1);
		$this->hr();
		if ($result) {
			$this->out('<success>' . __d('cake_installer', 'Creating symbolic links completed successfully.') . '</success>');
		} else {
			$this->out('<error>' . __d('cake_installer', 'Creating symbolic links unsuccessfully.') . '</error>');
		}

		return $result;
	}