Ubiquity
2.5.2
php rapid development framework
Loading...
Searching...
No Matches
URequestTesterTrait.php
Go to the documentation of this file.
1
<?php
2
3
namespace
Ubiquity\utils\http\traits
;
4
5
use
Ubiquity\controllers\Startup
;
6
15
class
URequestTesterTrait
{
16
24
public
static
function
filled
($key): bool {
25
return isset ( $_REQUEST [$key] ) && $_REQUEST [$key] != null;
26
}
27
35
public
static
function
has
($key): bool {
36
return isset ( $_REQUEST [$key] );
37
}
38
44
public
static
function
isAjax
(): bool {
45
return (isset ( $_SERVER [
'HTTP_X_REQUESTED_WITH'
] ) && ! empty ( $_SERVER [
'HTTP_X_REQUESTED_WITH'
] ) && strtolower ( $_SERVER [
'HTTP_X_REQUESTED_WITH'
] ) ==
'xmlhttprequest'
);
46
}
47
53
public
static
function
isPost
(): bool {
54
return $_SERVER [
'REQUEST_METHOD'
] ===
'POST'
;
55
}
56
66
public
static
function
isCrossSite
(): bool {
67
return \stripos ( $_SERVER [
'HTTP_REFERER'
], $_SERVER [
'SERVER_NAME'
] ) === FALSE;
68
}
69
75
public
static
function
isJSON
(): bool {
76
$contentType = self::getContentType ();
77
return \stripos ( $contentType,
'json'
) !==
false
;
78
}
79
85
public
static
function
getContentType
(): ?string {
86
$headers =
Startup
::getHttpInstance ()->getAllHeaders ();
87
if
(isset ( $headers [
'Content-Type'
] )) {
88
return
$headers [
'Content-Type'
];
89
}
90
return
null
;
91
}
92
}
93
Ubiquity\controllers\Startup
Starts the framework.
Definition
Startup.php:19
Ubiquity\utils\http\traits\URequestTesterTrait
Ubiquity\utils\http\traits$URequestTesterTrait This class is part of Ubiquity.
Definition
URequestTesterTrait.php:15
Ubiquity\utils\http\traits\URequestTesterTrait\isJSON
static isJSON()
Returns true if request contentType is set to json.
Definition
URequestTesterTrait.php:75
Ubiquity\utils\http\traits\URequestTesterTrait\getContentType
static getContentType()
Returns the request content-type header.
Definition
URequestTesterTrait.php:85
Ubiquity\utils\http\traits\URequestTesterTrait\isPost
static isPost()
Returns true if the request is sent by the POST method.
Definition
URequestTesterTrait.php:53
Ubiquity\utils\http\traits\URequestTesterTrait\isAjax
static isAjax()
Returns true if the request is an Ajax request.
Definition
URequestTesterTrait.php:44
Ubiquity\utils\http\traits\URequestTesterTrait\isCrossSite
static isCrossSite()
Returns true if the request is cross site.
Definition
URequestTesterTrait.php:66
Ubiquity\utils\http\traits\URequestTesterTrait\has
static has($key)
Tests if a value is present on the request.
Definition
URequestTesterTrait.php:35
Ubiquity\utils\http\traits\URequestTesterTrait\filled
static filled($key)
Tests if a value is present on the request and is not empty.
Definition
URequestTesterTrait.php:24
Ubiquity\utils\http\traits
Definition
URequestTesterTrait.php:3
C:
Users
myadd
Documents
GitHub
ubiquity-doc-api
vendor
phpmv
ubiquity
src
Ubiquity
utils
http
traits
URequestTesterTrait.php
Generated on Sun Dec 10 2023 15:04:27 for
Ubiquity
by
doxygen
1.9.8