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

orchestral / canvas / 6222379960

18 Sep 2023 12:18PM UTC coverage: 85.789% (-8.1%) from 93.885%
6222379960

Pull #25

github

web-flow
Merge 929673859 into 10f49b2ae
Pull Request #25: Use `Illuminate\Console\GeneratorCommand`

554 of 554 new or added lines in 33 files covered. (100.0%)

495 of 577 relevant lines covered (85.79%)

23.81 hits per line

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

26.09
/src/Canvas.php
1
<?php
2

3
namespace Orchestra\Canvas;
4

5
use Illuminate\Support\Arr;
6
use Illuminate\Support\Collection;
7

8
class Canvas
9
{
10
    /**
11
     * Assume the preset from environment.
12
     */
13
    public static function presetFromEnvironment(string $basePath): string
14
    {
15
        /** detect `testbench.yaml` */
16
        $testbenchYaml = Collection::make([
×
17
            'testbench.yaml',
×
18
            'testbench.yaml.example',
×
19
            'testbench.yaml.dist',
×
20
        ])->filter(fn ($filename) => file_exists($basePath.DIRECTORY_SEPARATOR.$filename))
×
21
            ->first();
×
22

23
        if (! \is_null($testbenchYaml)) {
×
24
            return 'package';
×
25
        }
26

27
        return Collection::make([
×
28
            file_exists($basePath.DIRECTORY_SEPARATOR.'artisan'),
×
29
            file_exists($basePath.DIRECTORY_SEPARATOR.'bootstrap'.DIRECTORY_SEPARATOR.'app.php'),
×
30
            is_dir($basePath.DIRECTORY_SEPARATOR.'bootstrap'.DIRECTORY_SEPARATOR.'cache'),
×
31
        ])->reject(fn ($condition) => $condition === true)
×
32
            ->isEmpty() ? 'laravel' : 'package';
×
33
    }
34

35
    /**
36
     * Make Preset from configuration.
37
     *
38
     * @param  array<string, mixed>  $config
39
     * @return \Orchestra\Canvas\Presets\Preset
40
     */
41
    public static function preset(array $config, string $basePath): Presets\Preset
42
    {
43
        /** @var array<string, mixed> $configuration */
44
        $configuration = Arr::except($config, 'preset');
71✔
45

46
        $preset = $config['preset'];
71✔
47

48
        switch ($preset) {
49
            case 'package':
71✔
50
                return new Presets\Package($configuration, $basePath);
1✔
51
            case 'laravel':
70✔
52
                return new Presets\Laravel($configuration, $basePath);
70✔
53
            default:
54
                if (class_exists($preset)) {
×
55
                    /**
56
                     * @var class-string<\Orchestra\Canvas\Presets\Preset> $preset
57
                     *
58
                     * @return \Orchestra\Canvas\Presets\Preset
59
                     */
60
                    return new $preset($configuration, $basePath);
×
61
                }
62

63
                return new Presets\Laravel($configuration, $basePath);
×
64
        }
65
    }
66
}
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