Skip to content

Commit

Permalink
Fix styling
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexVanderbist authored and github-actions[bot] committed Aug 25, 2023
1 parent 7f7a60f commit b9b6210
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 22 deletions.
10 changes: 5 additions & 5 deletions src/FileTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@

class FileTask
{
public string $file;
public string $file;

public function __construct(string $file)
{
$this->file = $file;
}
public function __construct(string $file)
{
$this->file = $file;
}
}
4 changes: 2 additions & 2 deletions src/Pool.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class Pool implements ArrayAccess

protected $binary = PHP_BINARY;

protected $max_input_size = 100000;
protected $max_input_size = 100000;

public function __construct()
{
Expand Down Expand Up @@ -150,7 +150,7 @@ public function add($process, ?int $outputLength = null): Runnable
$process,
$outputLength,
$this->binary,
$this->max_input_size
$this->max_input_size
);
}

Expand Down
30 changes: 15 additions & 15 deletions src/Runtime/ParentRuntime.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,29 +85,29 @@ public static function encodeTask($task, ?int $max_input_size = 100000): string
$task = new SerializableClosure($task);
}

//serialize the task. If it's too big to pass on the command line, then we'll have to write it to a file and pass the filename instead...
$serialized_task = base64_encode(serialize($task));
if (strlen($serialized_task) > $max_input_size) {
//write the serialized task to a temporary file...
$filename = tempnam(sys_get_temp_dir(), 'spatie_async_task_');
file_put_contents($filename, $serialized_task);
$file_task = new FileTask($filename);
$serialized_task = base64_encode(serialize($file_task));
}
//serialize the task. If it's too big to pass on the command line, then we'll have to write it to a file and pass the filename instead...
$serialized_task = base64_encode(serialize($task));
if (strlen($serialized_task) > $max_input_size) {
//write the serialized task to a temporary file...
$filename = tempnam(sys_get_temp_dir(), 'spatie_async_task_');
file_put_contents($filename, $serialized_task);
$file_task = new FileTask($filename);
$serialized_task = base64_encode(serialize($file_task));
}

return $serialized_task;
}

public static function decodeTask(string $task)
{
$decoded_task = unserialize(base64_decode($task));
if (get_class($decoded_task) == 'Spatie\Async\FileTask') {
$filename = $decoded_task->file;
$decoded_task = unserialize(base64_decode(file_get_contents($filename)));
unlink($filename);
}
if (get_class($decoded_task) == 'Spatie\Async\FileTask') {
$filename = $decoded_task->file;
$decoded_task = unserialize(base64_decode(file_get_contents($filename)));
unlink($filename);
}

return $decoded_task;
return $decoded_task;
}

protected static function getId(): string
Expand Down

0 comments on commit b9b6210

Please sign in to comment.