forked from yii2tech/filedb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
FileManager.php
49 lines (42 loc) · 1.18 KB
/
FileManager.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<?php
/**
* @link https://github.com/yii2tech
* @copyright Copyright (c) 2015 Yii2tech
* @license [New BSD License](http://www.opensource.org/licenses/bsd-license.php)
*/
namespace yii2tech\filedb;
use yii\base\Component;
/**
* FileManager is a base class for the file managers.
*
* @author Paul Klimov <[email protected]>
* @since 1.0
*/
abstract class FileManager extends Component
{
/**
* @var string data file extension to be used.
*/
public $fileExtension = 'dat';
/**
* Reads the data from data file.
* @param string $fileName file name without extension.
* @return array[] data.
*/
abstract public function readData($fileName);
/**
* Writes data into data file.
* @param string $fileName file name without extension.
* @param array $data data to be written.
*/
abstract public function writeData($fileName, array $data);
/**
* Composes data file actual name.
* @param string $fileName data file name without extension.
* @return string data file full name.
*/
protected function composeActualFileName($fileName)
{
return $fileName . '.' . $this->fileExtension;
}
}