mirror of
https://github.com/vitodeploy/vito.git
synced 2025-07-02 06:26:16 +00:00
Add phpstan level 7(#544)
This commit is contained in:
@ -13,7 +13,7 @@
|
||||
* @property int $server_log_id
|
||||
* @property ?int $server_id
|
||||
* @property string $user
|
||||
* @property array $variables
|
||||
* @property array<mixed> $variables
|
||||
* @property string $status
|
||||
* @property Carbon $created_at
|
||||
* @property Carbon $updated_at
|
||||
@ -23,6 +23,7 @@
|
||||
*/
|
||||
class ScriptExecution extends AbstractModel
|
||||
{
|
||||
/** @use HasFactory<\Database\Factories\ScriptExecutionFactory> */
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
@ -41,12 +42,18 @@ class ScriptExecution extends AbstractModel
|
||||
'variables' => 'array',
|
||||
];
|
||||
|
||||
/**
|
||||
* @var array<string, string>
|
||||
*/
|
||||
public static array $statusColors = [
|
||||
ScriptExecutionStatus::EXECUTING => 'warning',
|
||||
ScriptExecutionStatus::COMPLETED => 'success',
|
||||
ScriptExecutionStatus::FAILED => 'danger',
|
||||
];
|
||||
|
||||
/**
|
||||
* @return BelongsTo<Script, covariant $this>
|
||||
*/
|
||||
public function script(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Script::class);
|
||||
@ -56,7 +63,7 @@ public function getContent(): string
|
||||
{
|
||||
$content = $this->script->content;
|
||||
foreach ($this->variables as $variable => $value) {
|
||||
if (is_string($value) && ! empty($value)) {
|
||||
if (is_string($value) && ($value !== '' && $value !== '0')) {
|
||||
$content = str_replace('${'.$variable.'}', $value, $content);
|
||||
}
|
||||
}
|
||||
@ -64,11 +71,17 @@ public function getContent(): string
|
||||
return $content;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BelongsTo<ServerLog, covariant $this>
|
||||
*/
|
||||
public function serverLog(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(ServerLog::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BelongsTo<Server, covariant $this>
|
||||
*/
|
||||
public function server(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Server::class);
|
||||
|
Reference in New Issue
Block a user