/** * Stores value by key. * * @param string $key Cache key. * @param mixed $value Cache value. * @param integer $expire Expiration time, in seconds(optional). * * @access public * @uses Core\Helpers\File * * @return boolean */ public function store($key, $value, $expire = 0) { if ($expire) { $expire = time() + $expire; } $content = array($expire, $value); return File::putContents(self::storagePath() . self::generateName($key), json_encode($content)); }
/** * Migration generator. * * @param string $name Name string. * @param mixed $params Migration parameters. * * @return void */ public static function migration($name, $params) { if (is_array($params)) { $params = array_merge($params, array_slice(func_get_args(), 2)); } else { $params = array_slice(func_get_args(), 1); } $migration_name = strtolower($name) . '_' . time(); $tpl_vars = array('migration_name' => self::getMigrationName($migration_name), 'name' => explode('_', $name), 'fields' => array_map(function ($item) { return explode(':', $item); }, $params)); $path = Core\Config()->paths('root') . 'db' . DIRECTORY_SEPARATOR . 'migrations' . DIRECTORY_SEPARATOR; $result = self::parseTemplate('migration', $tpl_vars); Helpers\File::putContents($path . $migration_name . '.php', $result); }
/** * @covers Core\Helpers\File::putContents */ public function testPuttingContents() { $this->assertInternalType('int', File::putContents($this->uploadedFile, $this->fileRoot)); }