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

ICanBoogie / bind-activerecord / 4437492734

pending completion
4437492734

push

github

Olivier Laviale
Use ActiveRecord's SchemaBuilder

28 of 28 new or added lines in 5 files covered. (100.0%)

38 of 119 relevant lines covered (31.93%)

0.39 hits per line

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

0.0
/lib/ConfigBuilder.php
1
<?php
2

3
/*
4
 * This file is part of the ICanBoogie package.
5
 *
6
 * (c) Olivier Laviale <olivier.laviale@gmail.com>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11

12
namespace ICanBoogie\Binding\ActiveRecord;
13

14
use Closure;
15
use ICanBoogie\ActiveRecord;
16
use ICanBoogie\ActiveRecord\Config;
17
use ICanBoogie\ActiveRecord\Config\ConnectionDefinition;
18
use ICanBoogie\ActiveRecord\Model;
19
use ICanBoogie\ActiveRecord\Query;
20
use ICanBoogie\ActiveRecord\SchemaBuilder;
21
use ICanBoogie\Config\Builder;
22

23
/**
24
 * @implements Builder<Config>
25
 */
26
final class ConfigBuilder implements Builder
27
{
28
    public static function get_fragment_filename(): string
29
    {
30
        return 'activerecord';
×
31
    }
32

33
    private readonly ActiveRecord\ConfigBuilder $inner;
34

35
    public function __construct()
36
    {
37
        $this->inner = new ActiveRecord\ConfigBuilder();
×
38
    }
39

40
    public function build(): Config
41
    {
42
        return $this->inner->build();
×
43
    }
44

45
    /**
46
     * @return $this
47
     */
48
    public function add_connection(
49
        string $id,
50
        string $dsn,
51
        string|null $username = null,
52
        string|null $password = null,
53
        string|null $table_name_prefix = null,
54
        string $charset_and_collate = ConnectionDefinition::DEFAULT_CHARSET_AND_COLLATE,
55
        string $time_zone = ConnectionDefinition::DEFAULT_TIMEZONE,
56
    ): self {
57
        $this->inner->add_connection(
×
58
            id: $id,
×
59
            dsn: $dsn,
×
60
            username: $username,
×
61
            password: $password,
×
62
            table_name_prefix: $table_name_prefix,
×
63
            charset_and_collate: $charset_and_collate,
×
64
            time_zone: $time_zone
×
65
        );
×
66

67
        return $this;
×
68
    }
69

70
    /**
71
     * @param (Closure(SchemaBuilder $schema): SchemaBuilder) $schema_builder
72
     * @param class-string<ActiveRecord> $activerecord_class
73
     * @param class-string<Model<int|string, ActiveRecord>>|null $model_class
74
     * @param class-string<Query<ActiveRecord>>|null $query_class
75
     */
76
    public function add_model(
77
        string $id,
78
        Closure $schema_builder,
79
        string $activerecord_class,
80
        string $connection = Config::DEFAULT_CONNECTION_ID,
81
        string|null $name = null,
82
        string|null $alias = null,
83
        string|null $extends = null,
84
        string|null $implements = null,
85
        string|null $model_class = null,
86
        string|null $query_class = null,
87
        Closure $association_builder = null,
88
    ): self {
89
        $this->inner->add_model(
×
90
            id: $id,
×
91
            schema_builder: $schema_builder,
×
92
            activerecord_class: $activerecord_class,
×
93
            connection: $connection,
×
94
            name: $name,
×
95
            alias: $alias,
×
96
            extends: $extends,
×
97
            implements: $implements,
×
98
            model_class: $model_class,
×
99
            query_class: $query_class,
×
100
            association_builder: $association_builder,
×
101
        );
×
102

103
        return $this;
×
104
    }
105
}
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

© 2025 Coveralls, Inc