• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

SameOldNick / SameOldWebsite / 21471360437

29 Jan 2026 08:41AM UTC coverage: 87.487% (-0.02%) from 87.511%
21471360437

push

github

web-flow
Continues to next action if tests fail

28499 of 32575 relevant lines covered (87.49%)

696.55 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/app/Models/BackupConfig.php
1
<?php
2

3
namespace App\Models;
4

5
use Illuminate\Database\Eloquent\Model;
6

7
/**
8
 * @property int $id
9
 * @property string $key
10
 * @property string $value
11
 */
12
class BackupConfig extends Model
13
{
14
    /**
15
     * The table associated with the model.
16
     *
17
     * @var string|null
18
     */
19
    protected $table = 'backup_config';
20

21
    /**
22
     * Indicates if the model should be timestamped.
23
     *
24
     * @var bool
25
     */
26
    public $timestamps = false;
27

28
    /**
29
     * The attributes that are mass assignable.
30
     *
31
     * @var list<string>
32
     */
33
    protected $fillable = [
34
        'key',
35
        'value',
36
    ];
37

38
    /**
39
     * Updates or creates a BackupConfig model with key
40
     *
41
     * @param  callable(array): array  $callback  Existing items (if any) are passed and returned array is saved.
42
     */
43
    public static function updateOrCreateArrayValue(string $key, callable $callback): self
44
    {
45
        // Retrieve the existing configuration or create a new instance
46
        $backupConfig = self::firstOrNew(['key' => $key]);
×
47

48
        // Explode the value into an array if it exists; otherwise, use an empty array
49
        // Ensure 'value' is not empty as explode will change '' into [''] (not [])
50
        $items = $backupConfig->exists && $backupConfig->value ? explode(';', $backupConfig->value) : [];
×
51

52
        // Apply the callback to modify the array
53
        $updatedItems = $callback($items);
×
54

55
        // Update or create the configuration with the modified value
56
        $backupConfig->value = implode(';', $updatedItems);
×
57
        $backupConfig->save();
×
58

59
        return $backupConfig;
×
60
    }
61
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc