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

orchestral / canvas-core / 6168643703

13 Sep 2023 06:09AM UTC coverage: 71.818% (-22.4%) from 94.203%
6168643703

push

github

crynobone
Merge branch '8.x'

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

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

237 of 330 relevant lines covered (71.82%)

2.62 hits per line

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

66.67
/src/CodeGenerator.php
1
<?php
2

3
namespace Orchestra\Canvas\Core;
4

5
trait CodeGenerator
6
{
7
    /**
8
     * Canvas preset.
9
     *
10
     * @var \Orchestra\Canvas\Core\Presets\Preset
11
     */
12
    protected $preset;
13

14
    /**
15
     * Set Preset for generator.
16
     *
17
     * @return $this
18
     */
19
    public function setPreset(Presets\Preset $preset)
20
    {
21
        $this->preset = $preset;
×
22

23
        return $this;
×
24
    }
25

26
    /**
27
     * Generate code.
28
     *
29
     * @return int
30
     */
31
    public function generateCode(bool $force = false)
32
    {
33
        return $this->resolveGeneratesCodeProcessor()($force);
4✔
34
    }
35

36
    /**
37
     * Code already exists.
38
     */
39
    public function codeAlreadyExists(string $className): int
40
    {
41
        $this->components->error(sprintf('%s [%s] already exists!', $this->type, $className));
×
42

43
        return static::FAILURE;
×
44
    }
45

46
    /**
47
     * Code successfully generated.
48
     */
49
    public function codeHasBeenGenerated(string $className): int
50
    {
51
        $this->components->info(sprintf('%s [%s] created successfully.', $this->type, $className));
4✔
52

53
        return static::SUCCESS;
4✔
54
    }
55

56
    /**
57
     * Get the default namespace for the class.
58
     */
59
    public function getDefaultNamespace(string $rootNamespace): string
60
    {
61
        return $rootNamespace;
1✔
62
    }
63

64
    /**
65
     * Generator options.
66
     *
67
     * @return array<string, mixed>
68
     */
69
    public function generatorOptions(): array
70
    {
71
        return [
1✔
72
            'name' => $this->generatorName(),
1✔
73
        ];
1✔
74
    }
75

76
    /**
77
     * Resolve generates code processor.
78
     */
79
    protected function resolveGeneratesCodeProcessor(): GeneratesCode
80
    {
81
        /** @var \Orchestra\Canvas\Core\GeneratesCode $class */
82
        $class = property_exists($this, 'processor')
4✔
83
            ? $this->processor
4✔
84
            : GeneratesCode::class;
×
85

86
        return new $class($this->preset, $this);
4✔
87
    }
88
}
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