/** * @param string $area * @return bool */ public function isArea($area) { if (!self::match(self::PATTERN_AREA, $area)) { return false; } if ($this->config === null) { return true; } $areaDir = new File('private/src/area/' . $area . '/'); return $areaDir->isDir(); }
/** * write logs * * @param string $type * @param string $message * @throws RuntimeException if failed to create log-dir * @throws RuntimeException if log-file exists & is dir or link */ protected static function log($type, $message) { $now = new DateTime(); # create dir $logFile = new File(self::LOG_DIR . $now->format('Y-M')); if (!$logFile->isDir()) { $logFile->makeDir(); } # check file $logFile->attach($now->format('d') . '.log'); if (!$logFile->isFile() && $logFile->exists()) { throw new RuntimeException('log-file is not a file `' . $logFile . '`'); } # write log $time = $now->format('H:i:s'); $logFile->putContents('[' . $type . ' @ ' . $time . '] ' . $message . PHP_EOL); }