Skip to content

Commit

Permalink
Merge pull request #13 from dude920228/analysis-z39461
Browse files Browse the repository at this point in the history
Apply fixes from StyleCI
  • Loading branch information
dude920228 authored Nov 5, 2018
2 parents 3769d30 + 013a70d commit 017b8fd
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion example/Logger/CacheDataLogger.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public function __construct($logFilePath)
if (count($pathParts) > 1) {
unset($pathParts[count($pathParts) - 1]);
$this->logFileDir = implode('/', $pathParts);
if (! file_exists($this->logFileDir)) {
if (!file_exists($this->logFileDir)) {
mkdir($this->logFileDir);
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/CacheServer/ActionHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public function __invoke(
): ?bool {
$action = $data['action'];
$functionName = 'handle'.ucfirst($action);
if (! method_exists($this, $functionName)) {
if (!method_exists($this, $functionName)) {
return false;
}

Expand Down Expand Up @@ -48,7 +48,7 @@ private function handleGet(
): bool {
$key = $data['key'];
$package = $server->getBucket()->get($key);
if (! $package) {
if (!$package) {
return false;
}
if ($server->getEventListener()) {
Expand All @@ -67,7 +67,7 @@ private function handleDelete(
): bool {
$key = $data['key'];
$package = $server->getBucket()->get($key);
if (! $package) {
if (!$package) {
return false;
}
if ($server->getEventListener()) {
Expand Down
2 changes: 1 addition & 1 deletion src/Commands/GetCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ private function getEntry(InputInterface $input, OutputInterface $output)
/* @var $client CacheClient */
$client = $this->serviceManager->get(CacheClient::class);
$table = (new Table($output))->setHeaders(['KEY', 'VALUE']);
if (! is_null($key)) {
if (!is_null($key)) {
$value = $client->get($key);
if ($value === false) {
$output->writeln('<comment>No entry found for key: '.$key.'</comment>');
Expand Down
4 changes: 2 additions & 2 deletions src/IO/CacheIOHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function createServerSocket()
$socket = socket_create($socketType, SOCK_STREAM, 0);
socket_set_option($socket, SOL_SOCKET, SO_REUSEADDR, 1);
$bindResult = socket_bind($socket, $this->location, $this->serverPort);
if (! $bindResult) {
if (!$bindResult) {
$errorCode = socket_last_error($socket);
$errorMsg = socket_strerror($errorCode);

Expand Down Expand Up @@ -73,7 +73,7 @@ public function createClientSocket()
$this->location,
$this->serverPort
);
if (! $connectionResult) {
if (!$connectionResult) {
$errorCode = socket_last_error($socket);
$errorMsg = socket_strerror($errorCode);

Expand Down
6 changes: 3 additions & 3 deletions src/Storage/Bucket.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public function __construct(string $backupDir)

public function get(string $key): ?string
{
if (! array_key_exists($key, $this->entries) && ! $this->existsInBackup($key)) {
if (!array_key_exists($key, $this->entries) && !$this->existsInBackup($key)) {
return null;
}
if ($this->existsInBackup($key)) {
Expand All @@ -46,7 +46,7 @@ private function getFromBackup($key): string
$contents = '';
$handle = fopen($this->backupDir.'/'.$key.'.dat', 'r+');
if (is_resource($handle)) {
while (! feof($handle)) {
while (!feof($handle)) {
$contents .= fread($handle, 32);
}
}
Expand All @@ -59,7 +59,7 @@ public function store(string $key, string $entry, $time = null): bool
$compressed = gzcompress($entry, 9);
$this->entries[$key]['content'] = $compressed;
$this->entries[$key]['created_time'] = is_null($time) ? time() : $time;
if (! $compressed) {
if (!$compressed) {
return false;
}

Expand Down
6 changes: 3 additions & 3 deletions src/Storage/BucketFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public function __invoke(\Psr\Container\ContainerInterface $container)
$config = $container->getConfig();
$backupDir = $config['backupDir'];
$bucket = new Bucket($backupDir);
if (! file_exists($backupDir)) {
if (!file_exists($backupDir)) {
return $bucket;
}

Expand All @@ -24,12 +24,12 @@ public function __invoke(\Psr\Container\ContainerInterface $container)
private function restoreFromBackup($bucket, $backupDir)
{
foreach (new \DirectoryIterator($backupDir) as $file) {
if (! $file->isDot() && $file->isFile()) {
if (!$file->isDot() && $file->isFile()) {
$keyParts = explode('.', $file->getFilename());
$key = $keyParts[0];
$handle = $file->openFile('r');
$contents = '';
while (! $handle->eof()) {
while (!$handle->eof()) {
$contents .= $handle->fread(128);
}
if ($contents != '') {
Expand Down
2 changes: 1 addition & 1 deletion src/Storage/Maintainer.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ private function free(Bucket $bucket): void

private function createBackupDir(): void
{
if (! file_exists($this->backupDir)) {
if (!file_exists($this->backupDir)) {
mkdir($this->backupDir);
}
}
Expand Down

0 comments on commit 017b8fd

Please sign in to comment.