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

nepada / file-upload-control / 4581408359

pending completion
4581408359

Pull #103

github

GitHub
Merge ed661242b into c8546f895
Pull Request #103: Update nepada/coding-standard requirement from 7.6.0 to 7.7.0

641 of 710 relevant lines covered (90.28%)

0.9 hits per line

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

92.59
/src/FileUploadControl/Utils/NetteFileSystem.php
1
<?php
2
declare(strict_types = 1);
3

4
namespace Nepada\FileUploadControl\Utils;
5

6
use Nette;
7

8
final class NetteFileSystem implements FileSystem
9
{
10

11
    use Nette\SmartObject;
12

13
    public function fileExists(string $path): bool
1✔
14
    {
15
        return is_file($path);
1✔
16
    }
17

18
    public function fileSize(string $path): int
1✔
19
    {
20
        $size = @filesize($path);
1✔
21
        if ($size === false) {
1✔
22
            throw new \Exception("Unable to get file size '$path'. " . Nette\Utils\Helpers::getLastError());
×
23
        }
24
        return $size;
1✔
25
    }
26

27
    public function read(string $path): string
1✔
28
    {
29
        return Nette\Utils\FileSystem::read($path);
1✔
30
    }
31

32
    public function write(string $path, string $data): void
1✔
33
    {
34
        Nette\Utils\FileSystem::write($path, $data);
1✔
35
    }
1✔
36

37
    public function append(string $path, string $data): void
1✔
38
    {
39
        $this->createDirectory(dirname($path));
1✔
40

41
        if (@file_put_contents($path, $data, FILE_APPEND) === false) { // @ is escalated to exception
1✔
42
            throw new \Exception("Unable to write file '$path'. " . Nette\Utils\Helpers::getLastError());
×
43
        }
44
    }
1✔
45

46
    public function delete(string $path): void
1✔
47
    {
48
        Nette\Utils\FileSystem::delete($path);
1✔
49
    }
1✔
50

51
    public function directoryExists(string $path): bool
1✔
52
    {
53
        return is_dir($path);
1✔
54
    }
55

56
    public function createDirectory(string $path): void
1✔
57
    {
58
        Nette\Utils\FileSystem::createDir($path);
1✔
59
    }
1✔
60

61
    public function isWritable(string $path): bool
1✔
62
    {
63
        return is_writable($path);
1✔
64
    }
65

66
}
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