Skip to content

Commit

Permalink
Clean code
Browse files Browse the repository at this point in the history
  • Loading branch information
VennDev authored Jul 28, 2023
1 parent 9b09daa commit 237a2e4
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 11 deletions.
12 changes: 6 additions & 6 deletions src/vennv/vapm/Promise.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,12 +116,12 @@ public function getCallback(): callable;
/**
* This method is used to resolve the promise.
*/
public function resolve(mixed $value): void;
public function resolve(mixed $value = ''): void;

/**
* This method is used to reject the promise.
*/
public function reject(mixed $value): void;
public function reject(mixed $value = ''): void;

/**
* This method is used to set the callback when the promise is resolved.
Expand Down Expand Up @@ -226,12 +226,12 @@ public function __construct(callable $callback, bool $justGetResult = false)
}
else
{
$resolve = function($result): void
$resolve = function($result = ''): void
{
$this->resolve($result);
};

$reject = function($result): void
$reject = function($result = ''): void
{
$this->reject($result);
};
Expand Down Expand Up @@ -337,7 +337,7 @@ public function getCallback(): callable
return $this->callback;
}

public function resolve(mixed $value): void
public function resolve(mixed $value = ''): void
{
if ($this->isPending())
{
Expand All @@ -346,7 +346,7 @@ public function resolve(mixed $value): void
}
}

public function reject(mixed $value): void
public function reject(mixed $value = ''): void
{
if ($this->isPending())
{
Expand Down
19 changes: 14 additions & 5 deletions src/vennv/vapm/Stream.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,15 @@

use Generator;
use Throwable;
use function fclose;
use function fgets;
use function file_exists;
use function fopen;
use function fwrite;
use function stream_set_blocking;
use function touch;
use function unlink;
use const PHP_EOL;

interface StreamInterface
{
Expand Down Expand Up @@ -141,7 +150,7 @@ public static function write(string $path, string $data): Promise

$callback($path, $data);

$resolve('');
$resolve();
}, 0);
});
}
Expand Down Expand Up @@ -173,7 +182,7 @@ public static function append(string $path, string $data): Promise

$callback($path, $data);

$resolve('');
$resolve();
}, 0);
});
}
Expand Down Expand Up @@ -201,7 +210,7 @@ public static function delete(string $path): Promise

$callback($path);

$resolve('');
$resolve();
}, 0);
});
}
Expand Down Expand Up @@ -229,7 +238,7 @@ public static function create(string $path): Promise

$callback($path);

$resolve('');
$resolve();
}, 0);
});
}
Expand Down Expand Up @@ -261,7 +270,7 @@ public static function overWrite(string $path, string $data): Promise

$callback($path, $data);

$resolve('');
$resolve();
}, 0);
});
}
Expand Down

0 comments on commit 237a2e4

Please sign in to comment.