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

ICanBoogie / bind-activerecord / 4325699063

pending completion
4325699063

push

github

Olivier Laviale
Use SchemaBuilder

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

57 of 134 relevant lines covered (42.54%)

0.51 hits per line

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

62.5
/lib/Hooks.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 ICanBoogie\ActiveRecord;
15
use ICanBoogie\ActiveRecord\ActiveRecordCache\RuntimeActiveRecordCache;
16
use ICanBoogie\ActiveRecord\Model;
17
use ICanBoogie\ActiveRecord\ModelProvider;
18
use ICanBoogie\ActiveRecord\ModelResolver;
19
use ICanBoogie\ActiveRecord\StaticModelResolver;
20
use ICanBoogie\Application;
21
use ICanBoogie\Validate\ValidationErrors;
22

23
final class Hooks
24
{
25
    /*
26
     * Events
27
     */
28

29
    /**
30
     * Define model provider.
31
     *
32
     * Models are provided using the model collection bound to the application.
33
     */
34
    public static function on_app_boot(Application\BootEvent $event): void
35
    {
36
        $app = $event->app;
×
37

38
        ActiveRecord\StaticModelProvider::define(function (string $id) use ($app): Model {
×
39
            static $models;
×
40

41
            $models ??= $app->service_for_class(ModelProvider::class);
×
42

43
            return $models->model_for_id($id);
×
44
        });
×
45

46
        StaticModelResolver::define(
2✔
47
            static function () use ($app): ModelResolver {
2✔
48
                static $resolver;
2✔
49

50
                return $resolver ??= $app->service_for_class(ModelResolver::class);
2✔
51
            }
2✔
52
        );
2✔
53
    }
54

55
    /*
56
     * Prototypes
57
     */
58

59
    /**
60
     * @return array<string, mixed>|ValidationErrors
61
     */
62
    public static function active_record_validate(ActiveRecord $record): array|ValidationErrors
63
    {
64
        static $validate;
2✔
65

66
        $validate ??= new ActiveRecord\Validate\ValidateActiveRecord();
2✔
67

68
        return $validate($record);
2✔
69
    }
70

71
    /**
72
     * Returns the records cache associated with the model.
73
     */
74
    public static function model_lazy_get_activerecord_cache(Model $model): RuntimeActiveRecordCache
75
    {
76
        return new RuntimeActiveRecordCache($model);
1✔
77
    }
78
}
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