Skip to content

Commit 56fbd09

Browse files
committed
Fix coding standards
1 parent 33c48cd commit 56fbd09

4 files changed

Lines changed: 45 additions & 27 deletions

File tree

packages/Filesystem/src/Filesystem.php

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111

1212
namespace Aether\Filesystem;
1313

14-
class Filesystem implements FilesystemInterface {
15-
14+
class Filesystem implements FilesystemInterface
15+
{
1616
public function exists(string $path): bool
1717
{
1818
if (\strlen($path) > \PHP_MAXPATHLEN - 2) {
@@ -24,7 +24,7 @@ public function exists(string $path): bool
2424

2525
public function read(string $path): string
2626
{
27-
if (!$this->exists($path) && !$this->isFile($path)) {
27+
if (! $this->exists($path) && ! $this->isFile($path)) {
2828
throw new IOException("File $path does not exists.");
2929
}
3030

@@ -81,14 +81,16 @@ public function mkdir(string $directory, int $mode = 0777, bool $recursive = fal
8181
throw new IOException("Failed to create a directory '".$directory."'.");
8282
}
8383
}
84-
public function rmdir(string $directory): void {
85-
if (!$this->isDirectory($directory)) {
84+
85+
public function rmdir(string $directory): void
86+
{
87+
if (! $this->isDirectory($directory)) {
8688
throw new IOException("Directory $directory does not exists.");
8789
}
8890

8991
$items = new \FilesystemIterator($directory);
9092
foreach ($items as $item) {
91-
$item->isDir() && !$item->isLink()
93+
$item->isDir() && ! $item->isLink()
9294
? $this->rmdir($item->getPathname())
9395
: $this->unlink($item->getPathname());
9496
}
@@ -119,14 +121,13 @@ public function extension(string $path): string
119121

120122
public function filesize(string $path): int
121123
{
122-
if (!$this->exists($path)) {
124+
if (! $this->exists($path)) {
123125
throw new IOException("File $path does not exists.");
124126
}
125127

126128
return \filesize($path);
127129
}
128130

129-
130131
public function isDirectory(string $path): bool
131132
{
132133
return \is_dir($path);
@@ -139,7 +140,7 @@ public function isFile(string $path): bool
139140

140141
public function mimeType(string $path): string
141142
{
142-
if (!$this->exists($path)) {
143+
if (! $this->exists($path)) {
143144
throw new IOException("File not found $path");
144145
}
145146

packages/Filesystem/src/FilesystemInterface.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111

1212
namespace Aether\Filesystem;
1313

14-
interface FilesystemInterface {
14+
interface FilesystemInterface
15+
{
1516
/**
1617
* Checks if a file exists at the given path.
1718
*

packages/Filesystem/src/IOException.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@
1111

1212
namespace Aether\Filesystem;
1313

14-
class IOException extends \RuntimeException {
15-
14+
class IOException extends \RuntimeException
15+
{
1616
}

packages/Filesystem/tests/FilesystemTest.php

Lines changed: 31 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,74 +17,85 @@
1717
use PHPUnit\Framework\TestCase;
1818

1919
#[CoversClass(Filesystem::class)]
20-
class FilesystemTest extends TestCase {
20+
class FilesystemTest extends TestCase
21+
{
2122
private ?string $tempDir;
2223
private FilesystemInterface $filesystem;
2324

24-
protected function setUp(): void {
25+
protected function setUp(): void
26+
{
2527
$this->filesystem = new Filesystem();
2628
$this->tempDir = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'tmp';
2729
$this->filesystem->mkdir($this->tempDir);
2830
}
2931

30-
protected function tearDown(): void {
32+
protected function tearDown(): void
33+
{
3134
if ($this->filesystem->exists($this->tempDir)) {
3235
$this->filesystem->rmdir($this->tempDir);
3336
}
3437

3538
$this->tempDir = null;
3639
}
3740

38-
public function testFileExists(): void {
41+
public function testFileExists(): void
42+
{
3943
$basePath = $this->tempDir . DIRECTORY_SEPARATOR;
4044
$this->filesystem->touch($basePath . 'file.txt');
4145

4246
self::assertFalse($this->filesystem->exists($basePath . 'file122.txt'));
4347
self::assertTrue($this->filesystem->exists($basePath . 'file.txt'));
4448
}
4549

46-
public function testReadFileContent(): void {
50+
public function testReadFileContent(): void
51+
{
4752
$basePath = $this->tempDir . DIRECTORY_SEPARATOR . 'file1.txt';
4853
\file_put_contents($basePath, 'test content');
4954
self::assertSame('test content', $this->filesystem->read($basePath));
5055
}
5156

52-
public function testWriteFile(): void {
57+
public function testWriteFile(): void
58+
{
5359
$basePath = $this->tempDir . DIRECTORY_SEPARATOR . 'file.txt';
5460

5561
$this->filesystem->write($basePath, 'test content');
5662
self::assertSame('test content', $this->filesystem->read($basePath));
5763
}
5864

59-
public function testAppendContentToFile(): void {
65+
public function testAppendContentToFile(): void
66+
{
6067
$basePath = $this->tempDir . DIRECTORY_SEPARATOR . 'file.txt';
6168
$this->filesystem->write($basePath, 'test content');
6269
$this->filesystem->append($basePath, 'test content');
6370

6471
self::assertSame('test contenttest content', $this->filesystem->read($basePath));
6572
}
6673

67-
public function testRemoveFiles(): void {
74+
public function testRemoveFiles(): void
75+
{
6876
$basePath = $this->tempDir . DIRECTORY_SEPARATOR . 'file1.txt';
6977
$this->filesystem->touch($basePath);
7078
$this->filesystem->unlink($basePath);
7179

7280
self::assertFalse($this->filesystem->exists($basePath));
7381
}
7482

75-
public function testRemoveDirectory(): void {
83+
public function testRemoveDirectory(): void
84+
{
7685
$this->filesystem->mkdir($this->tempDir . DIRECTORY_SEPARATOR . 'dir');
7786
$this->filesystem->rmdir($this->tempDir);
7887

7988
self::assertFalse($this->filesystem->exists($this->tempDir));
8089
}
8190

82-
public function testRemoveDirectoryRecursive(): void {
91+
public function testRemoveDirectoryRecursive(): void
92+
{
8393
$this->filesystem->mkdir($this->tempDir . DIRECTORY_SEPARATOR . 'dir' . DIRECTORY_SEPARATOR . 'dir1', 0777, true);
8494
$this->filesystem->rmdir($this->tempDir);
8595

8696
self::assertFalse($this->filesystem->exists($this->tempDir));
8797
}
98+
8899
public function testCopyFile()
89100
{
90101
$source = $this->tempDir . '/file1.txt';
@@ -110,35 +121,40 @@ public function testMoveFile()
110121
self::assertEquals('test content', $this->filesystem->read($destination));
111122
}
112123

113-
public function testName(): void {
124+
public function testName(): void
125+
{
114126
$file = $this->tempDir . DIRECTORY_SEPARATOR .'file1.txt';
115127
$this->filesystem->touch($file);
116128

117129
self::assertSame('file1', $this->filesystem->name($file));
118130
}
119131

120-
public function testDirname(): void {
132+
public function testDirname(): void
133+
{
121134
$file = $this->tempDir . DIRECTORY_SEPARATOR .'file1.txt';
122135
$this->filesystem->touch($file);
123136

124137
self::assertSame('/tmp/tmp', $this->filesystem->dirname($file));
125138
}
126139

127-
public function testBasename(): void {
140+
public function testBasename(): void
141+
{
128142
$file = $this->tempDir . DIRECTORY_SEPARATOR .'file1.txt';
129143
$this->filesystem->touch($file);
130144

131145
self::assertSame('file1.txt', $this->filesystem->basename($file));
132146
}
133147

134-
public function testExtension(): void {
148+
public function testExtension(): void
149+
{
135150
$file = $this->tempDir . DIRECTORY_SEPARATOR .'file1.txt';
136151
$this->filesystem->touch($file);
137152

138153
self::assertSame('txt', $this->filesystem->extension($file));
139154
}
140155

141-
public function testFileSize(): void {
156+
public function testFileSize(): void
157+
{
142158
$file = $this->tempDir . DIRECTORY_SEPARATOR .'file1.txt';
143159
$this->filesystem->touch($file);
144160

0 commit comments

Comments
 (0)