Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Format code with php-cs-fixer #8

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 11 additions & 23 deletions src/lib/module.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ class Bedrock_Module extends \Wordpress_Module

protected function getAppRoot(string $hostname, string $path = ''): ?string
{
if (file_exists($tmp = $this->getDocumentRoot($hostname, $path) . '/wp-config.php'))
{
if (file_exists($tmp = $this->getDocumentRoot($hostname, $path) . '/wp-config.php')) {
return $tmp;
}

Expand All @@ -29,19 +28,14 @@ protected function getAppRoot(string $hostname, string $path = ''): ?string

protected function getAppRootPath(string $hostname, string $path = ''): ?string
{
if ($hostname[0] === '/')
{
if (!($path = realpath($this->domain_fs_path($hostname))))
{
if ($hostname[0] === '/') {
if (!($path = realpath($this->domain_fs_path($hostname)))) {
return null;
}
$approot = \dirname($path);
}
else
{
} else {
$approot = $this->getAppRoot($hostname, $path);
if (!$approot)
{
if (!$approot) {
return null;
}
$approot = $this->domain_fs_path($approot);
Expand Down Expand Up @@ -76,17 +70,15 @@ public function get_versions(): array

// Attempt to retrieve cached versions
$cache = \Cache_Super_Global::spawn();
if (false !== ($ver = $cache->get($key)))
{
if (false !== ($ver = $cache->get($key))) {
return $ver;
}

// Retrieve package information for version check
$url = self::VERSION_CHECK_URL;
$context = stream_context_create(['http' => ['timeout' => 5]]);
$contents = file_get_contents($url, false, $context);
if (!$contents)
{
if (!$contents) {
return array();
}
$versions = json_decode($contents, true);
Expand Down Expand Up @@ -118,16 +110,14 @@ public function valid(string $hostname, string $path = ''): bool

public function get_version(string $hostname, string $path = ''): ?string
{
if (!$this->valid($hostname, $path))
{
if (!$this->valid($hostname, $path)) {
return null;
}

$approot = $this->getAppRootPath($hostname, $path);

// is composer.json file missing?
if (!file_exists($approot . '/composer.json'))
{
if (!file_exists($approot . '/composer.json')) {
return null;
}

Expand All @@ -139,8 +129,7 @@ public function get_environment(string $hostname, string $path = ''): ?string
$approot = $this->getAppRootPath($hostname, $path);

// is .env file missing?
if (!file_exists($approot . '/.env'))
{
if (!file_exists($approot . '/.env')) {
return null;
}

Expand Down Expand Up @@ -175,8 +164,7 @@ public function get_environments(string $hostname, string $path = ''): ?array
$approotpath = $this->getAppRootPath($hostname, $path);

// is config/environments/ dir missing?
if (!is_dir($approotpath . '/config/environments/'))
{
if (!is_dir($approotpath . '/config/environments/')) {
return null;
}

Expand Down