/library/Application/Config/Format/Serialize.php
PHP | 54 lines | 25 code | 8 blank | 21 comment | 0 complexity | 3970aac7f66725c4439c95e4f1f065b5 MD5 | raw file
- <?php
- namespace Nano\Application\Config\Format;
- class Serialize implements \Nano\Application\Config\Format {
- /**
- * @return boolean
- */
- public function available() {
- return true;
- }
- /**
- * @return stdClass
- * @param string $fileName
- */
- public function read($fileName) {
- $result = file_get_contents($fileName);
- $result = unSerialize($result);
- return $result;
- }
- /**
- * @return \Nano\Routes
- * @param string $fileName
- */
- public function readRoutes($fileName) {
- return $this->read($fileName);
- }
- /**
- * @return boolean
- * @param array $data
- * @param string $fileName
- */
- public function write(array $data, $fileName) {
- $source = serialize(json_decode(json_encode($data)));
- file_put_contents($fileName, $source);
- return true;
- }
- /**
- * @return boolean
- * @param \Nano\Routes $routes
- * @param string $fileName
- */
- public function writeRoutes(\Nano\Routes $routes, $fileName) {
- $source = serialize($routes);
- file_put_contents($fileName, $source);
- return true;
- }
- }