File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ <?php
2+ /*
3+ * This file is part of the Nigatedev PHP framework package
4+ *
5+ * (c) Abass Ben Cheik <abass@todaysdev.com>
6+ */
7+
8+ namespace Nigatedev \Filesystem \Exceptions ;
9+
10+ class DirNotFoundException extends \Exception implements FileExceptionInterface
11+ {
12+
13+ }
Original file line number Diff line number Diff line change 1+ <?php
2+ /*
3+ * This file is part of the Nigatedev PHP framework package
4+ *
5+ * (c) Abass Ben Cheik <abass@todaysdev.com>
6+ */
7+
8+ namespace Nigatedev \Filesystem \Exceptions ;
9+
10+ /**
11+ * Filesystem exception interface
12+ *
13+ * @author Abass Ben Cheik <abass@todaysdev.com>
14+ */
15+ interface FileExceptionInterface extends \Throwable
16+ {
17+
18+ }
Original file line number Diff line number Diff line change 1+ <?php
2+ /*
3+ * This file is part of the Nigatedev PHP framework package
4+ *
5+ * (c) Abass Ben Cheik <abass@todaysdev.com>
6+ */
7+
8+ namespace Nigatedev \Filesystem \Exceptions ;
9+
10+ class FileNotFoundException extends \Exception implements FileExceptionInterface
11+ {
12+
13+ }
Original file line number Diff line number Diff line change 11<?php
22/*
3- * This file is part of the Nigatedev PHP framework
3+ * This file is part of the Nigatedev PHP framework package
44 *
55 * (c) Abass Ben Cheik <abass@todaysdev.com>
66 */
77
88namespace Nigatedev \Filesystem ;
99
10+ use Nigatedev \Filesystem \Exceptions \FileNotFoundException ;
11+ use Nigatedev \Filesystem \Exceptions \DirNotFoundException ;
12+
1013/**
1114 * The Nigatedev PHP framework filesystem manipulator
1215 *
1316 * @author Abass Ben Cheik <abass@todaysdev.com>
1417 */
1518class Filesystem {
1619
20+ /**
21+ * @var string $fieName
22+ */
23+ private string $ fieName ;
24+
25+ public function isFile ($ fieName ): bool
26+ {
27+ if (!file_exists ($ fieName )) {
28+ throw new FileNotFoundException ("Fatal error: {$ fieName } file not found " );
29+ }
30+ return true ;
31+ }
32+
33+ public function isFilePut ($ fieName )
34+ {
35+ if ($ this ->isFile ($ fieName )) {
36+ return file_put_contents ($ fieName );
37+ }
38+ }
39+
40+ public function isDir ($ dirName )
41+ {
42+ if (!is_dir ($ dirName )) {
43+ throw new DirNotFoundException ("Fatal error: {$ dirName } directory not found " );
44+ }
45+ return true ;
46+ }
1747}
You can’t perform that action at this time.
0 commit comments