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

orchestral / canvas / 6224137920

18 Sep 2023 02:42PM UTC coverage: 90.984% (+1.0%) from 89.945%
6224137920

push

github

crynobone
wip

Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>

603 of 603 new or added lines in 34 files covered. (100.0%)

555 of 610 relevant lines covered (90.98%)

24.54 hits per line

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

96.43
/src/CanvasServiceProvider.php
1
<?php
2

3
namespace Orchestra\Canvas;
4

5
use Illuminate\Contracts\Foundation\Application;
6
use Illuminate\Contracts\Support\DeferrableProvider;
7
use Illuminate\Support\Arr;
8
use Illuminate\Support\ServiceProvider;
9
use Orchestra\Canvas\Core\PresetManager;
10
use Symfony\Component\Yaml\Yaml;
11

12
class CanvasServiceProvider extends ServiceProvider implements DeferrableProvider
13
{
14
    /**
15
     * Register services.
16
     *
17
     * @return void
18
     */
19
    public function register(): void
20
    {
21
        $this->callAfterResolving(PresetManager::class, function ($manager, $app) {
93✔
22
            $manager->extend('canvas', function ($app) {
93✔
23
                return new GeneratorPreset($app);
93✔
24
            });
93✔
25

26
            $manager->setDefaultDriver('canvas');
93✔
27
        });
93✔
28

29
        $this->app->singleton('orchestra.canvas', function (Application $app) {
93✔
30
            $workingPath = \defined('CANVAS_WORKING_PATH') ? CANVAS_WORKING_PATH : $this->app->basePath();
72✔
31

32
            $filesystem = $app->make('files');
72✔
33

34
            $config = ['preset' => 'laravel'];
72✔
35

36
            if (file_exists($workingPath.DIRECTORY_SEPARATOR.'canvas.yaml')) {
72✔
37
                $config = Yaml::parseFile($workingPath.DIRECTORY_SEPARATOR.'canvas.yaml');
×
38
            } else {
39
                Arr::set($config, 'testing.extends', [
72✔
40
                    'unit' => 'PHPUnit\Framework\TestCase',
72✔
41
                    'feature' => 'Tests\TestCase',
72✔
42
                ]);
72✔
43

44
                $config['namespace'] = rescue(fn () => rtrim($this->app->getNamespace(), '\\'), null, false);
72✔
45
            }
46

47
            return Canvas::preset($config, $workingPath);
72✔
48
        });
93✔
49
    }
50

51
    /**
52
     * Bootstrap services.
53
     */
54
    public function boot(): void
55
    {
56
        if ($this->app->runningInConsole()) {
93✔
57
            $this->commands([
93✔
58
                Console\CodeMakeCommand::class,
93✔
59
                Console\GeneratorMakeCommand::class,
93✔
60
                Console\PresetMakeCommand::class,
93✔
61
            ]);
93✔
62
        }
63
    }
64

65
    /**
66
     * Get the services provided by the provider.
67
     *
68
     * @return array<int, string>
69
     */
70
    public function provides()
71
    {
72
        return [
1✔
73
            'orchestra.canvas',
1✔
74
        ];
1✔
75
    }
76
}
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