CreateParametresTable   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
eloc 14
c 0
b 0
f 0
dl 0
loc 34
ccs 0
cts 12
cp 0
rs 10
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A up() 0 12 1
A down() 0 3 1
A __construct() 0 4 1
1
<?php
2
3
declare(strict_types=1);
4
5
/**
6
 * This file is part of BlitzPHP Parametres.
7
 *
8
 * (c) 2025 Dimitri Sitchet Tomkeu <[email protected]>
9
 *
10
 * For the full copyright and license information, please view
11
 * the LICENSE file that was distributed with this source code.
12
 */
13
14
namespace BlitzPHP\Parametres\Database\Migrations;
15
16
use BlitzPHP\Database\Migration\Migration;
17
use BlitzPHP\Database\Migration\Structure;
18
use stdClass;
19
20
class CreateParametresTable extends Migration
21
{
22
    private stdClass $config;
23
24
    public function __construct()
25
    {
26
        $this->config = (object) config('parametres');
27
        $this->group  = $this->config->database['group'] ?? 'default';
28
    }
29
30
    /**
31
     * {@inheritDoc}
32
     */
33
    public function up(): void
34
    {
35
        $this->create($this->config->database['table'], static function (Structure $table) {
36
            $table->id();
37
            $table->string('file');
38
            $table->string('key');
39
            $table->text('value')->nullable();
40
            $table->string('type', 31)->default('string');
41
            $table->string('context')->nullable();
42
            $table->timestamps();
43
44
            return $table;
45
        });
46
    }
47
48
    /**
49
     * {@inheritDoc}
50
     */
51
    public function down(): void
52
    {
53
        $this->dropIfExists($this->config->database['table']);
54
    }
55
}
56