Skip to content

Commit

Permalink
added docs for undocumented function & method
Browse files Browse the repository at this point in the history
  • Loading branch information
UnknownRori committed Jun 1, 2022
1 parent c55da95 commit 449309c
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
16 changes: 15 additions & 1 deletion core/http/response/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class Response implements IResponse

public function __construct()
{

//
}

public function __destruct()
Expand All @@ -32,6 +32,9 @@ public function __destruct()

/**
* Send out json response along with http response code
* @param array $response
* @param int $code
* @return self
*/
public function json(array $response, int $code = 200): self
{
Expand All @@ -43,12 +46,23 @@ public function json(array $response, int $code = 200): self
return $this;
}

/**
* add additional header to response
* @param string $header
* @param string $value
* @return self
*/
public function header(string $header, string $value): self
{
$this->headers[$header] = $value;
return $this;
}

/**
* add additional headers to response
* @param $headers
* @return self
*/
public function withHeaders(array $headers): self
{
$headerKey = array_keys($headers);
Expand Down
8 changes: 8 additions & 0 deletions core/utils/helpers/function/csrf.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,20 @@

use Core\Http\CSRF;

/**
* Generate hidden field contain csrf token
* @return string
*/
function csrf()
{
$token = session()->get(CSRF::$session);
return "<input name='_csrf_token' value=" . $token ." hidden ></input>";
}

/**
* Get csrf token
* @return string
*/
function csrf_token()
{
return session()->get(CSRF::$session);
Expand Down
4 changes: 4 additions & 0 deletions core/utils/helpers/function/exception.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
<?php

/**
* Throw an exception
* @return void
*/
function report($message = "")
{
if (env('APP_DEBUG', true)) throw new Exception($message);
Expand Down

0 comments on commit 449309c

Please sign in to comment.