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

orchestral / canvas / 5911156259

19 Aug 2023 11:35AM UTC coverage: 95.793% (-0.9%) from 96.723%
5911156259

Pull #22

github

web-flow
Merge d074609f4 into ee912994c
Pull Request #22: Workbench code generators

12 of 12 new or added lines in 2 files covered. (100.0%)

797 of 832 relevant lines covered (95.79%)

21.55 hits per line

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

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

3
namespace Orchestra\Canvas;
4

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

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

20
        if (! \is_null($testbenchYaml)) {
×
21
            return 'package';
×
22
        }
23

24

25
    }
26

27
    /**
28
     * Make Preset from configuration.
29
     *
30
     * @param  array<string, mixed>  $config
31
     * @return \Orchestra\Canvas\Core\Presets\Preset
32
     */
33
    public static function preset(array $config, string $workingPath, Filesystem $files): Core\Presets\Preset
34
    {
35
        /** @var array<string, mixed> $configuration */
36
        $configuration = Arr::except($config, 'preset');
72✔
37

38
        $preset = $config['preset'];
72✔
39

40
        switch ($preset) {
41
            case 'package':
72✔
42
                return new Core\Presets\Package($configuration, $workingPath, $files);
1✔
43
            case 'laravel':
71✔
44
                return new Core\Presets\Laravel($configuration, $workingPath, $files);
71✔
45
            default:
46
                if (class_exists($preset)) {
×
47
                    /**
48
                     * @var class-string<\Orchestra\Canvas\Core\Presets\Preset> $preset
49
                     *
50
                     * @return \Orchestra\Canvas\Core\Presets\Preset
51
                     */
52
                    return new $preset($configuration, $workingPath, $files);
×
53
                }
54

55
                return new Core\Presets\Laravel($configuration, $basePath, $files);
×
56
        }
57
    }
58
}
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