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

ICanBoogie / bind-activerecord / 6138450705

10 Sep 2023 05:10PM UTC coverage: 34.513% (-0.3%) from 34.821%
6138450705

push

github

olvlvl
ICanBoogie/ActiveRecord update

1 of 1 new or added line in 1 file covered. (100.0%)

39 of 113 relevant lines covered (34.51%)

0.37 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\SchemaBuilder;
20
use ICanBoogie\Config\Builder;
21

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

32
    private readonly ActiveRecord\ConfigBuilder $inner;
33

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

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

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

66
        return $this;
×
67
    }
68

69
    /**
70
     * @param class-string<ActiveRecord> $activerecord_class
71
     * @param class-string<Model> $model_class
72
     * @param (Closure(SchemaBuilder $schema): SchemaBuilder)|null $schema_builder
73
     */
74
    public function add_model(
75
        string $activerecord_class,
76
        string $model_class = Model::class,
77
        string|null $table_name = null,
78
        string|null $alias = null,
79
        Closure $schema_builder = null,
80
        Closure $association_builder = null,
81
        string $connection = Config::DEFAULT_CONNECTION_ID,
82
    ): self {
83
        $this->inner->add_model(
×
84
            activerecord_class: $activerecord_class,
×
85
            model_class: $model_class,
×
86
            table_name: $table_name,
×
87
            alias: $alias,
×
88
            schema_builder: $schema_builder,
×
89
            association_builder: $association_builder,
×
90
            connection: $connection,
×
91
        );
×
92

93
        return $this;
×
94
    }
95

96
    /**
97
     * @return $this
98
     */
99
    public function use_attributes(): self
100
    {
101
        $this->inner->use_attributes();
×
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