Example #1
0
 /**
  * Writes a log
  *
  * @param StatusCode $err
  * @param string $additional
  */
 public static function write($err, $additional = '')
 {
     $dt = new DateTime();
     $file = App::logs()->file('log_' . $dt->format('Y-m-d') . '.log');
     $log = $dt->format('H:i:s') . "\t" . $err->status() . "\t{$additional}\r\n";
     if ($file->exists()) {
         $file->append($log);
     } else {
         $file->write($log);
     }
     self::clean();
 }
Example #2
0
 public function getHeadLine()
 {
     $rp = $this->_reasonPhrase;
     if (!$rp) {
         $rp = StatusCode::getReasonPhrase($this->_statusCode);
     }
     return implode(' ', [$this->getProtocol() . '/' . $this->getProtocolVersion(), $this->_statusCode, $rp]);
 }
 public function make(string $name, UrlInterface $url, ResponseInterface $response) : HttpResource
 {
     $headers = $response->headers();
     if ($response->statusCode()->value() !== StatusCode::codes()->get('OK') || !$headers->has('Content-Type') || (string) $headers->get('Content-Type')->values()->current() !== 'application/json') {
         throw new InvalidArgumentException();
     }
     $data = json_decode((string) $response->body(), true);
     $data['url'] = (string) $url;
     return $this->denormalizer->denormalize($data, HttpResource::class, null, ['name' => $name]);
 }
Example #4
0
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
	"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>

	<title><?php 
echo StatusCode::http_header_for($code);
?>
</title>
	
	<style type="text/css" media="screen">
		BODY {
			font-family: verdana, tahoma, arial, helvetica, sans-serif;
			font-size: 12px;
			margin: 0px;
			padding: 16px;
		}
		
		CODE {
			margin: 0px;
			padding: 0px;
		}
		
		A {
			color: #000;
		}
		
		A:hover {
			background-color: #F5F5F5;
Example #5
0
 function process_exception($object)
 {
     $this->error = $object;
     $this->message = $object->getMessage();
     $this->details = $object->getDetails();
     $this->code = $object->getCode();
     $this->trace = $object->getTrace();
     if ($this->code != 0) {
         header(StatusCode::http_header_for($this->code));
     }
     $paths = array('_errors', 'framework/_errors');
     foreach ($paths as $path) {
         if (is_file(APP_ROOT . '/' . $path . '/' . $this->code . '.' . Framework::$views_extension)) {
             $view_file = APP_ROOT . '/' . $path . '/' . $this->code . '.' . Framework::$views_extension;
             break;
         } elseif (is_file(APP_ROOT . '/' . $path . '/default.' . Framework::$views_extension)) {
             $view_file = APP_ROOT . '/' . $path . '/default.' . Framework::$views_extension;
             break;
         }
     }
     if (StatusCode::can_has_body($this->code)) {
         $this->render_file($view_file);
     }
 }