Skip to content

Commit

Permalink
Send clipboard-ready data to Ray.
Browse files Browse the repository at this point in the history
  • Loading branch information
timvandijck committed Aug 28, 2023
1 parent 66d011b commit 3668485
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/Payloads/LogPayload.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ class LogPayload extends Payload
/** @var array */
protected $values;

/** @var array */
protected $meta = [];

public static function createForArguments(array $arguments): Payload
{
$dumpedArguments = array_map(function ($argument) {
Expand All @@ -28,6 +31,10 @@ public function __construct($values)
$values = [$values];
}

foreach ($values as $key => $value) {
$this->meta[$key]['clipboard_data'] = $this->getClipboardData($value);
}

$this->values = $values;
}

Expand All @@ -40,6 +47,16 @@ public function getContent(): array
{
return [
'values' => $this->values,
'meta' => $this->meta,
];
}

protected function getClipboardData(mixed $value): string
{
if (is_string($value) || is_numeric($value)) {
return (string) $value;
}

return var_export($value, true);
}
}

0 comments on commit 3668485

Please sign in to comment.