Skip to content

Commit 77c2312

Browse files
authored
Add a new contracts package (#7)
1 parent 4d054de commit 77c2312

7 files changed

Lines changed: 49 additions & 30 deletions

File tree

composer.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
"aether/cache": "self.version",
2929
"aether/clock": "self.version",
3030
"aether/config": "self.version",
31+
"aether/contracts": "self.version",
3132
"aether/crypto": "self.version",
3233
"aether/database": "self.version",
3334
"aether/dependency-injection": "self.version",
@@ -54,6 +55,7 @@
5455
"Aether\\Cache\\": "packages/Cache/src/",
5556
"Aether\\Clock\\": "packages/Clock/src/",
5657
"Aether\\Config\\": "packages/Config/src/",
58+
"Aether\\Contracts\\": "packages/Contracts/",
5759
"Aether\\Crypto\\": "packages/Crypto/src/",
5860
"Aether\\Database\\": "packages/Database/src/",
5961
"Aether\\DependencyInjection\\": "packages/DependencyInjection/src/",

packages/Filesystem/src/FilesystemInterface.php renamed to packages/Contracts/Filesystem/Filesystem.php

Lines changed: 14 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,15 @@
11
<?php
22

3-
/*
4-
* This file is part of the aether/aether.
5-
*
6-
* Copyright (C) 2024 Dominik Szamburski
7-
*
8-
* This software may be modified and distributed under the terms
9-
* of the MIT license. See the LICENSE file for details.
10-
*/
11-
12-
namespace Aether\Filesystem;
13-
14-
interface FilesystemInterface
3+
namespace Aether\Contracts\Filesystem;
4+
5+
interface Filesystem
156
{
167
/**
178
* Checks if a file exists at the given path.
189
*
1910
* @param string $path
2011
* @return bool
21-
* @throws \Aether\Filesystem\IOException
12+
* @throws \Aether\Contracts\Filesystem\IOException
2213
*/
2314
public function exists(string $path): bool;
2415

@@ -37,7 +28,7 @@ public function read(string $path): string;
3728
* @param string $contents
3829
* @param bool $lock
3930
* @return void
40-
* @throws \Aether\Filesystem\IOException
31+
* @throws \Aether\Contracts\Filesystem\IOException
4132
*/
4233
public function write(string $path, string $contents, bool $lock = false): void;
4334

@@ -46,10 +37,9 @@ public function write(string $path, string $contents, bool $lock = false): void;
4637
*
4738
* @param string $source
4839
* @param string $destination
49-
50-
* @return void
40+
* @return void
5141
*
52-
* @throws \Aether\Filesystem\IOException
42+
* @throws \Aether\Contracts\Filesystem\IOException
5343
*/
5444
public function copy(string $source, string $destination): void;
5545

@@ -61,7 +51,7 @@ public function copy(string $source, string $destination): void;
6151
*
6252
* @return void
6353
*
64-
* @throws \Aether\Filesystem\IOException
54+
* @throws \Aether\Contracts\Filesystem\IOException
6555
*/
6656
public function move(string $source, string $destination): void;
6757

@@ -86,10 +76,10 @@ public function touch(string $filename, ?int $mtime = null, ?int $atime = null):
8676
/**
8777
* Deletes a file.
8878
*
89-
* @param string|array $filename
79+
* @param string|string[] $filename
9080
* @return void
9181
*
92-
* @throws \Aether\Filesystem\IOException
82+
* @throws \Aether\Contracts\Filesystem\IOException
9383
*/
9484
public function unlink(string|array $filename): void;
9585

@@ -102,7 +92,7 @@ public function unlink(string|array $filename): void;
10292
*
10393
* @return void
10494
*
105-
* @throws \Aether\Filesystem\IOException
95+
* @throws \Aether\Contracts\Filesystem\IOException
10696
*/
10797
public function mkdir(string $directory, int $mode = 0777, bool $recursive = true): void;
10898

@@ -112,7 +102,7 @@ public function mkdir(string $directory, int $mode = 0777, bool $recursive = tru
112102
* @param string $directory
113103
* @return void
114104
*
115-
* @throws \Aether\Filesystem\IOException
105+
* @throws \Aether\Contracts\Filesystem\IOException
116106
*/
117107
public function rmdir(string $directory): void;
118108

@@ -154,7 +144,7 @@ public function extension(string $path): string;
154144
* @param string $path
155145
* @return int
156146
*
157-
* @throws \Aether\Filesystem\IOException
147+
* @throws \Aether\Contracts\Filesystem\IOException
158148
*/
159149
public function filesize(string $path): int;
160150

@@ -180,7 +170,7 @@ public function isFile(string $path): bool;
180170
* @param string $path
181171
* @return string
182172
*
183-
* @throws \Aether\Filesystem\IOException
173+
* @throws \Aether\Contracts\Filesystem\IOException
184174
*/
185175
public function mimeType(string $path): string;
186176
}

packages/Filesystem/src/IOException.php renamed to packages/Contracts/Filesystem/IOException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* of the MIT license. See the LICENSE file for details.
1010
*/
1111

12-
namespace Aether\Filesystem;
12+
namespace Aether\Contracts\Filesystem;
1313

1414
class IOException extends \RuntimeException
1515
{

packages/Contracts/composer.json

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"name": "aether/contracts",
3+
"description": "The Aether contracts package.",
4+
"license": "MIT",
5+
"type": "library",
6+
"support": {
7+
"issues": "https://github.com/sxbrsky/aether/issues",
8+
"source": "https://github.com/sxbrsky/aether"
9+
},
10+
"require": {
11+
"php": "^8.2",
12+
"ext-fileinfo": "*"
13+
},
14+
"minimum-stability": "dev",
15+
"autoload": {
16+
"psr-4": {
17+
"Aether\\Contracts\\": ""
18+
}
19+
},
20+
"config": {
21+
"sort-packages": true
22+
}
23+
}

packages/Filesystem/composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
},
1010
"require": {
1111
"php": "^8.2",
12-
"ext-fileinfo": "*"
12+
"ext-fileinfo": "*",
13+
"aether/contract": "dev-master"
1314
},
1415
"minimum-stability": "dev",
1516
"autoload": {

packages/Filesystem/src/Filesystem.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
namespace Aether\Filesystem;
4+
35
/*
46
* This file is part of the aether/aether.
57
*
@@ -9,9 +11,10 @@
911
* of the MIT license. See the LICENSE file for details.
1012
*/
1113

12-
namespace Aether\Filesystem;
14+
use Aether\Contracts\Filesystem\Filesystem as FilesystemContract;
15+
use Aether\Contracts\Filesystem\IOException;
1316

14-
class Filesystem implements FilesystemInterface
17+
class Filesystem implements FilesystemContract
1518
{
1619
public function exists(string $path): bool
1720
{

packages/Filesystem/tests/FilesystemTest.php

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

1212
namespace Aether\Tests\Filesystem;
1313

14+
use Aether\Contracts\Filesystem\Filesystem as FilesystemContract;
1415
use Aether\Filesystem\Filesystem;
15-
use Aether\Filesystem\FilesystemInterface;
1616
use PHPUnit\Framework\Attributes\CoversClass;
1717
use PHPUnit\Framework\TestCase;
1818

1919
#[CoversClass(Filesystem::class)]
2020
class FilesystemTest extends TestCase
2121
{
2222
private ?string $tempDir;
23-
private FilesystemInterface $filesystem;
23+
private FilesystemContract $filesystem;
2424

2525
protected function setUp(): void
2626
{

0 commit comments

Comments
 (0)