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

api-platform / core / 13203378522

07 Feb 2025 03:56PM UTC coverage: 8.501% (+0.7%) from 7.837%
13203378522

push

github

soyuka
Merge 4.1

111 of 490 new or added lines in 51 files covered. (22.65%)

5590 existing lines in 163 files now uncovered.

13345 of 156987 relevant lines covered (8.5%)

22.88 hits per line

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

0.0
/src/Laravel/Console/Maker/Utils/StateTemplateGenerator.php
1
<?php
2

3
/*
4
 * This file is part of the API Platform project.
5
 *
6
 * (c) Kévin Dunglas <dunglas@gmail.com>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11

12
declare(strict_types=1);
13

14
namespace ApiPlatform\Laravel\Console\Maker\Utils;
15

16
use Illuminate\Contracts\Filesystem\FileNotFoundException;
17
use Illuminate\Filesystem\Filesystem;
18

19
final readonly class StateTemplateGenerator
20
{
21
    public function __construct(private Filesystem $filesystem)
22
    {
23
    }
×
24

25
    public function getFilePath(string $directoryPath, string $stateFileName): string
26
    {
27
        return $directoryPath.$stateFileName.'.php';
×
28
    }
29

30
    /**
31
     * @throws FileNotFoundException
32
     */
33
    public function generate(string $pathLink, string $stateClassName, StateTypeEnum $stateTypeEnum): void
34
    {
35
        $namespace = 'App\\State';
×
36
        $template = $this->loadTemplate($stateTypeEnum);
×
37

38
        $content = strtr($template, [
×
39
            '{{ namespace }}' => $namespace,
×
40
            '{{ class_name }}' => $stateClassName,
×
41
        ]);
×
42

43
        $this->filesystem->put($pathLink, $content);
×
44
    }
45

46
    /**
47
     * @throws FileNotFoundException
48
     */
49
    private function loadTemplate(StateTypeEnum $stateTypeEnum): string
50
    {
51
        $templateFile = match ($stateTypeEnum) {
×
NEW
52
            StateTypeEnum::Provider => 'StateProvider.php.tpl',
×
NEW
53
            StateTypeEnum::Processor => 'StateProcessor.php.tpl',
×
54
        };
×
55

56
        $templatePath = \dirname(__DIR__).'/Resources/skeleton/'.$templateFile;
×
57

58
        return $this->filesystem->get($templatePath);
×
59
    }
60
}
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