Skip to content

Commit 465a49e

Browse files
committed
PHPDoc, demo and function changes
- [Change] Fixed useless PHPDoc stuff - [Change] Function `FileInfo::getInfo` is now `FileInfo::scan` - [Change] Return now an array `instead` of `object` - [New] Added demo project **Breaking Changes**
1 parent cda790a commit 465a49e

9 files changed

+95
-7
lines changed

Diff for: .gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
vendor
2-
.phpdoc
2+
.phpdoc
3+
message.txt

Diff for: composer.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,7 @@
1515
}
1616
],
1717
"minimum-stability": "stable",
18-
"require": {}
18+
"require-dev": {
19+
"phpstan/phpstan": "^1.11"
20+
}
1921
}

Diff for: composer.lock

+77
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: demo/fileinfo.php

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?php
2+
require __DIR__.'/../vendor/autoload.php';
3+
4+
$fi = new Trihydera\File\FileInfo(__DIR__.'/files');
5+
6+
echo json_encode(
7+
$fi->scan()
8+
);

Diff for: demo/files/test1.txt

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
lorem lipsum lorem lipsum lorem lipsum

Diff for: demo/files/text2.txt

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
lorem lipsum lorem lipsum lorem lipsum lorem lipsum

Diff for: src/FileInfo.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public function __construct($dir)
2626
*
2727
* @return array An array containing details of files in the directory.
2828
*/
29-
public function getInfo()
29+
public function scan()
3030
{
3131
$details = [];
3232
$this->listFilesRecursively($this->dir, $details);
@@ -59,7 +59,7 @@ private function listFilesRecursively($dir, &$details)
5959
$formattedSize = $this->formatSize($size);
6060
$shortCode = substr($hash, 2, 4) . substr($hash, 10, 4);
6161

62-
$details[$file] = [
62+
$details[] = [
6363
'id' => $shortCode,
6464
'name' => $file,
6565
'modified' => date('Y-m-d H:i', $modified),

Diff for: src/FileTypes.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class FileTypes
1212
/**
1313
* Array containing file types with their categories and purposes.
1414
*
15-
* @var array
15+
* @var array List of file types
1616
*/
1717
public $types = [
1818
'exe' => ['category' => 'Windows', 'purpose' => 'Executable file'],

Diff for: src/JsonFile.php

-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ class JsonFile
1414
*
1515
* @param string $file The path to the JSON file.
1616
* @return array The decoded JSON data.
17-
* @throws \Exception If the file path is invalid.
1817
*/
1918
public function read($file)
2019
{
@@ -27,7 +26,6 @@ public function read($file)
2726
*
2827
* @param string $file The path to the JSON file.
2928
* @param array $data The data to be encoded as JSON and written to the file.
30-
* @throws \Exception If the file path is invalid.
3129
*/
3230
public function write($file, $data)
3331
{

0 commit comments

Comments
 (0)