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

DoclerLabs / api-client-generator / 7259428899

19 Dec 2023 08:47AM UTC coverage: 89.733% (-0.3%) from 90.043%
7259428899

push

github

web-flow
Merge pull request #102 from DoclerLabs/generator-php-8

generator php 8

355 of 381 new or added lines in 40 files covered. (93.18%)

6 existing lines in 4 files now uncovered.

2657 of 2961 relevant lines covered (89.73%)

3.35 hits per line

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

82.61
/src/Output/DirectoryPrinter.php
1
<?php
2

3
declare(strict_types=1);
4

5
namespace DoclerLabs\ApiClientGenerator\Output;
6

7
use RuntimeException;
8

9
class DirectoryPrinter
10
{
11
    public function ensureDirectoryExists(string $directoryPath): void
12
    {
13
        $isSuccessful = is_dir($directoryPath)
4✔
14
                        || mkdir($directoryPath, 0755, true)
4✔
UNCOV
15
                        || is_dir($directoryPath);
×
16

17
        if (!$isSuccessful) {
4✔
18
            throw new RuntimeException(sprintf('Directory "%s" could not be created', $directoryPath));
×
19
        }
20
    }
4✔
21

22
    public function move(string $destinationPath, string $sourcePath): void
23
    {
24
        $this->ensureDirectoryExists($sourcePath);
2✔
25
        $this->delete($destinationPath);
2✔
26

27
        rename($sourcePath, $destinationPath);
2✔
28
    }
2✔
29

30
    public function delete(string $path): bool
31
    {
32
        if (!file_exists($path)) {
3✔
33
            return true;
2✔
34
        }
35

36
        if (!is_dir($path)) {
2✔
37
            return unlink($path);
1✔
38
        }
39

40
        $directoryContent = scandir($path);
2✔
41
        if ($directoryContent === false) {
2✔
42
            return true;
×
43
        }
44

45
        foreach ($directoryContent as $item) {
2✔
46
            if ($item === '.' || $item === '..') {
2✔
47
                continue;
2✔
48
            }
49

50
            if (!$this->delete($path . DIRECTORY_SEPARATOR . $item)) {
1✔
51
                return false;
×
52
            }
53
        }
54

55
        return rmdir($path);
2✔
56
    }
57
}
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