Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
n/a
0 / 0
n/a
0 / 0
CRAP
n/a
0 / 0
1<?php
2/**
3 * Jingga
4 *
5 * PHP Version 8.1
6 *
7 * @package   phpOMS\System\File
8 * @copyright Dennis Eichhorn
9 * @license   OMS License 2.0
10 * @version   1.0.0
11 * @link      https://jingga.app
12 */
13declare(strict_types=1);
14
15namespace phpOMS\System\File\Ftp;
16
17use phpOMS\System\File\ContainerInterface;
18
19/**
20 * Filesystem class.
21 *
22 * Performing operations on the file system
23 *
24 * @package phpOMS\System\File
25 * @license OMS License 2.0
26 * @link    https://jingga.app
27 * @since   1.0.0
28 */
29interface FtpContainerInterface extends ContainerInterface
30{
31    /**
32     * Get the datetime when the resource got created.
33     *
34     * @param \FTP\Connection $con  FTP connection
35     * @param string          $path Path of the resource
36     *
37     * @return \DateTime
38     *
39     * @since 1.0.0
40     */
41    public static function created(\FTP\Connection $con, string $path) : \DateTime;
42
43    /**
44     * Get the datetime when the resource got last modified.
45     *
46     * @param \FTP\Connection $con  FTP connection
47     * @param string          $path Path of the resource
48     *
49     * @return \DateTime
50     *
51     * @since 1.0.0
52     */
53    public static function changed(\FTP\Connection $con, string $path) : \DateTime;
54
55    /**
56     * Get the owner id of the resource.
57     *
58     * @param \FTP\Connection $con  FTP connection
59     * @param string          $path Path of the resource
60     *
61     * @return string
62     *
63     * @since 1.0.0
64     */
65    public static function owner(\FTP\Connection $con, string $path) : string;
66
67    /**
68     * Get the permissions id of the resource.
69     *
70     * @param \FTP\Connection $con  FTP connection
71     * @param string          $path Path of the resource
72     *
73     * @return int Permissions (e.g. 0755);
74     *
75     * @since 1.0.0
76     */
77    public static function permission(\FTP\Connection $con, string $path) : int;
78
79    /**
80     * Get the parent path of the resource.
81     *
82     * The parent resource path is always a directory.
83     *
84     * @param string $path Path of the resource
85     *
86     * @return string
87     *
88     * @since 1.0.0
89     */
90    public static function parent(string $path) : string;
91
92    /**
93     * Delete resource at destination path.
94     *
95     * @param \FTP\Connection $con  FTP connection
96     * @param string          $path Path of the resource
97     *
98     * @return bool True on success and false on failure
99     *
100     * @since 1.0.0
101     */
102    public static function delete(\FTP\Connection $con, string $path) : bool;
103
104    /**
105     * Copy resource to different location.
106     *
107     * @param \FTP\Connection $con       FTP connection
108     * @param string          $from      Path of the resource to copy
109     * @param string          $to        Path of the resource to copy to
110     * @param bool            $overwrite Overwrite/replace existing file
111     *
112     * @return bool True on success and false on failure
113     *
114     * @since 1.0.0
115     */
116    public static function copy(\FTP\Connection $con, string $from, string $to, bool $overwrite = false) : bool;
117
118    /**
119     * Move resource to different location.
120     *
121     * @param \FTP\Connection $con       FTP connection
122     * @param string          $from      Path of the resource to move
123     * @param string          $to        Path of the resource to move to
124     * @param bool            $overwrite Overwrite/replace existing file
125     *
126     * @return bool True on success and false on failure
127     *
128     * @since 1.0.0
129     */
130    public static function move(\FTP\Connection $con, string $from, string $to, bool $overwrite = false) : bool;
131
132    /**
133     * Get size of resource.
134     *
135     * @param \FTP\Connection $con       FTP connection
136     * @param string          $path      Path of the resource
137     * @param bool            $recursive Should include sub-sub-resources
138     *
139     * @return int
140     *
141     * @since 1.0.0
142     */
143    public static function size(\FTP\Connection $con, string $path, bool $recursive = true) : int;
144
145    /**
146     * Check existence of resource.
147     *
148     * @param \FTP\Connection $con  FTP connection
149     * @param string          $path Path of the resource
150     *
151     * @return bool
152     *
153     * @since 1.0.0
154     */
155    public static function exists(\FTP\Connection $con, string $path) : bool;
156
157    /**
158     * Get name of resource.
159     *
160     * @param string $path Path of the resource
161     *
162     * @return string
163     *
164     * @since 1.0.0
165     */
166    public static function name(string $path) : string;
167
168    /**
169     * Get basename of resource.
170     *
171     * @param string $path Path of the resource
172     *
173     * @return string
174     *
175     * @since 1.0.0
176     */
177    public static function basename(string $path) : string;
178
179    /**
180     * Get the directory name of the resource.
181     *
182     * @param string $path Path of the resource
183     *
184     * @return string
185     *
186     * @since 1.0.0
187     */
188    public static function dirname(string $path) : string;
189
190    /**
191     * Get the directory path of the resource.
192     *
193     * @param string $path Path of the resource
194     *
195     * @return string
196     *
197     * @since 1.0.0
198     */
199    public static function dirpath(string $path) : string;
200
201    /**
202     * Count subresources.
203     *
204     * @param \FTP\Connection $con       FTP connection
205     * @param string          $path      Path of the resource
206     * @param bool            $recursive Consider subdirectories
207     * @param string[]        $ignore    Files/paths to ignore (no regex)
208     *
209     * @return int
210     *
211     * @since 1.0.0
212     */
213    public static function count(\FTP\Connection $con, string $path, bool $recursive = true, array $ignore = []) : int;
214
215    /**
216     * Make name/path operating system safe.
217     *
218     * @param string $path    Path of the resource
219     * @param string $replace Replace invalid chars with
220     * @param string $invalid Invalid chars to sanitize
221     *
222     * @return string
223     *
224     * @since 1.0.0
225     */
226    public static function sanitize(string $path, string $replace = '', string $invalid = '/[^\w\s\d\.\-_~,;\/\[\]\(\]]/') : string;
227}