Skip to content

Commit ebef239

Browse files
committed
Apply changes;
1 parent b665010 commit ebef239

File tree

3 files changed

+9
-12
lines changed

3 files changed

+9
-12
lines changed

src/Drivers/LocalDriver.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ public function __construct()
1616

1717
$this->config = config('auto-doc.drivers.local');
1818

19-
$directory = str_ends_with($this->config['directory'], DIRECTORY_SEPARATOR)
19+
$directory = (str_ends_with($this->config['directory'], DIRECTORY_SEPARATOR))
2020
? $this->config['directory']
2121
: $this->config['directory'] . DIRECTORY_SEPARATOR;
2222

23-
$this->mainFilePath = storage_path("$directory{$this->config['base_file_name']}.json");
23+
$this->mainFilePath = storage_path("{$directory}{$this->config['base_file_name']}.json");
2424

2525
if (empty($this->config['base_file_name']) || !str_ends_with($this->mainFilePath, '.json')) {
2626
throw new MissedProductionFilePathException();
@@ -30,6 +30,7 @@ public function __construct()
3030
public function saveData(): void
3131
{
3232
$documentationDirectory = storage_path($this->config['directory']);
33+
3334
if (!is_dir($documentationDirectory)) {
3435
mkdir($documentationDirectory);
3536
}

src/Drivers/StorageDriver.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@ public function __construct()
2020
$this->config = config('auto-doc.drivers.storage');
2121
$this->disk = Storage::disk($this->config['disk']);
2222

23-
$directory = str_ends_with($this->config['directory'], DIRECTORY_SEPARATOR)
23+
$directory = (str_ends_with($this->config['directory'], DIRECTORY_SEPARATOR))
2424
? $this->config['directory']
2525
: $this->config['directory'] . DIRECTORY_SEPARATOR;
2626

27-
$this->mainFilePath = "$directory{$this->config['base_file_name']}.json";
27+
$this->mainFilePath = "{$directory}{$this->config['base_file_name']}.json";
2828

29-
if (!preg_match('/\/[\w]+\.json/ms', $this->mainFilePath)) {
29+
if (empty($this->config['base_file_name']) || !str_ends_with($this->mainFilePath, '.json')) {
3030
throw new MissedProductionFilePathException();
3131
}
3232
}

tests/AutoDocControllerTest.php

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,18 @@ class AutoDocControllerTest extends TestCase
1212
use PHPMock;
1313

1414
protected static array $documentation;
15-
protected static string $baseFile;
1615

1716
public function setUp(): void
1817
{
1918
parent::setUp();
2019

21-
$documentationDirectory = config('auto-doc.drivers.local.directory');
22-
23-
self::$baseFile ??= $documentationDirectory.'/documentation.json';
2420
self::$documentation ??= $this->getJsonFixture('tmp_data');
2521

26-
if (!is_dir(storage_path($documentationDirectory))) {
27-
mkdir(storage_path($documentationDirectory));
22+
if (!is_dir(storage_path('documentations'))) {
23+
mkdir(storage_path('documentations'));
2824
}
2925

30-
file_put_contents(storage_path(self::$baseFile), json_encode(self::$documentation));
26+
file_put_contents(storage_path('documentations/documentation.json'), json_encode(self::$documentation));
3127

3228
config(['auto-doc.drivers.local.base_file_name' => 'documentation']);
3329
}

0 commit comments

Comments
 (0)