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

orchestral / canvas-core / 6167235202

13 Sep 2023 02:26AM UTC coverage: 80.247%. Remained the same
6167235202

push

github

crynobone
wip

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

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

65 of 81 relevant lines covered (80.25%)

1.99 hits per line

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

73.68
/src/Presets/Package.php
1
<?php
2

3
namespace Orchestra\Canvas\Core\Presets;
4

5
use Illuminate\Support\Arr;
6
use InvalidArgumentException;
7
use Symfony\Component\Console\Application;
8

9
class Package extends Preset
10
{
11
    /**
12
     * List of global generators.
13
     *
14
     * @var array<int, class-string<\Symfony\Component\Console\Command\Command>>
15
     */
16
    protected static $generators = [];
17

18
    /**
19
     * Add global command.
20
     *
21
     * @param  array<int, class-string<\Symfony\Component\Console\Command\Command>>  $generators
22
     */
23
    public static function commands(array $generators): void
24
    {
25
        static::$generators = array_merge(static::$generators, $generators);
×
26
    }
27

28
    /**
29
     * Preset name.
30
     */
31
    public function name(): string
32
    {
33
        return 'package';
1✔
34
    }
35

36
    /**
37
     * Get the path to the base working directory.
38
     */
39
    public function laravelPath(): string
40
    {
41
        return sprintf('%s/orchestra/testbench-core/laravel', $this->vendorPath());
1✔
42
    }
43

44
    /**
45
     * Get the path to the source directory.
46
     */
47
    public function sourcePath(): string
48
    {
49
        return sprintf(
1✔
50
            '%s/%s',
1✔
51
            $this->basePath(),
1✔
52
            $this->config('paths.src', 'src')
1✔
53
        );
1✔
54
    }
55

56
    /**
57
     * Preset namespace.
58
     */
59
    public function rootNamespace(): string
60
    {
61
        $namespace = trim($this->config['namespace'] ?? '');
4✔
62

63
        if (empty($namespace)) {
4✔
64
            throw new InvalidArgumentException("Please configure namespace configuration under 'canvas.yaml'");
1✔
65
        }
66

67
        return $namespace;
3✔
68
    }
69

70
    /**
71
     * Testing namespace.
72
     */
73
    public function testingNamespace(): string
74
    {
75
        return $this->config('testing.namespace', $this->rootNamespace().'\Tests');
×
76
    }
77

78
    /**
79
     * Model namespace.
80
     */
81
    public function modelNamespace(): string
82
    {
83
        return $this->config('model.namespace', $this->rootNamespace());
3✔
84
    }
85

86
    /**
87
     * Provider namespace.
88
     */
89
    public function providerNamespace(): string
90
    {
91
        return $this->config('provider.namespace', $this->rootNamespace());
3✔
92
    }
93

94
    /**
95
     * Get custom stub path.
96
     */
97
    public function getCustomStubPath(): ?string
98
    {
99
        return sprintf('%s/stubs', $this->basePath());
1✔
100
    }
101

102
    /**
103
     * Sync commands to preset.
104
     */
105
    public function addAdditionalCommands(Application $app): void
106
    {
107
        parent::addAdditionalCommands($app);
×
108

109
        foreach (Arr::wrap(static::$generators) as $generator) {
×
110
            /** @var class-string<\Symfony\Component\Console\Command\Command> $generator */
111
            $app->add(new $generator($this));
×
112
        }
113
    }
114
}
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