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

tempestphp / tempest-framework / 11834579899

14 Nov 2024 09:41AM UTC coverage: 82.65% (+0.05%) from 82.602%
11834579899

Pull #726

github

web-flow
Merge ecef5860e into 0bdee919e
Pull Request #726: fix(console): handle nested `style` tags

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

26 existing lines in 5 files now uncovered.

7617 of 9216 relevant lines covered (82.65%)

51.59 hits per line

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

81.25
/src/Tempest/Generation/src/ClassManipulator.php
1
<?php
2

3
declare(strict_types=1);
4

5
namespace Tempest\Generation;
6

7
use Nette\PhpGenerator\ClassType;
8
use Nette\PhpGenerator\PhpFile;
9
use ReflectionClass;
10
use Tempest\Generation\Exceptions\FileGenerationFailedException;
11

12
final class ClassManipulator
13
{
14
    use ManipulatesPhpClasses;
15

16
    public function __construct(string|ReflectionClass $source)
25✔
17
    {
18
        if (is_file($source)) {
25✔
19
            /** @phpstan-ignore-next-line */
20
            $this->classType = ClassType::fromCode(file_get_contents($source));
4✔
21
        } elseif (is_string($source)) {
21✔
22
            /** @phpstan-ignore-next-line */
23
            $this->classType = ClassType::from($source, withBodies: true);
21✔
24
        } else {
25
            /** @phpstan-ignore-next-line */
UNCOV
26
            $this->classType = ClassType::from($source->getName(), withBodies: true);
×
27
        }
28

29
        $this->file = new PhpFile();
24✔
30
        $this->namespace = $this->classType->getNamespace()->getName();
24✔
31
    }
32

33
    /**
34
     * Save the class to a target file.
35
     *
36
     * @param string $path the path to save the class to.
37
     *
38
     * @throws FileGenerationFailedException if the file could not be written.
39
     */
40
    public function save(string $path): self
8✔
41
    {
42
        $dir = pathinfo($path, PATHINFO_DIRNAME);
8✔
43

44
        if (! is_dir($dir)) {
8✔
UNCOV
45
            mkdir($dir, recursive: true);
×
46
        }
47

48
        $isSuccess = (bool) file_put_contents($path, $this->print());
8✔
49

50
        if (! $isSuccess) {
8✔
UNCOV
51
            throw new FileGenerationFailedException(sprintf('The file "%s" could not be written.', $path));
×
52
        }
53

54
        return $this;
8✔
55
    }
56
}
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