Updated src folder
This commit is contained in:
parent
b79188a07e
commit
6392ceef55
21 changed files with 55 additions and 52 deletions
|
@ -9,9 +9,14 @@ use Appwrite\Auth\OAuth2;
|
|||
|
||||
class Box extends OAuth2
|
||||
{
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $endpoint = 'https://account.box.com/api/oauth2/';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $resourceEndpoint = 'https://api.box.com/2.0/';
|
||||
|
||||
/**
|
||||
|
@ -19,6 +24,9 @@ class Box extends OAuth2
|
|||
*/
|
||||
protected $user = [];
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $scopes = [
|
||||
'manage_app_users',
|
||||
];
|
||||
|
@ -148,5 +156,4 @@ class Box extends OAuth2
|
|||
|
||||
return $this->user;
|
||||
}
|
||||
|
||||
}
|
|
@ -232,7 +232,7 @@ class MySQL extends Adapter
|
|||
|
||||
// Handle array of relations
|
||||
if (self::DATA_TYPE_ARRAY === $type) {
|
||||
if(!is_array($value)) { // Property should be of type array, if not = skip
|
||||
if (!is_array($value)) { // Property should be of type array, if not = skip
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
|
@ -452,7 +452,7 @@ class Database
|
|||
$filters = $rule->getAttribute('filter', null);
|
||||
$value = $document->getAttribute($key, null);
|
||||
|
||||
if(($value !== null) && is_array($filters)) {
|
||||
if (($value !== null) && is_array($filters)) {
|
||||
foreach ($filters as $filter) {
|
||||
$value = $this->encodeAttribute($filter, $value);
|
||||
$document->setAttribute($key, $value);
|
||||
|
@ -473,7 +473,7 @@ class Database
|
|||
$filters = $rule->getAttribute('filter', null);
|
||||
$value = $document->getAttribute($key, null);
|
||||
|
||||
if(($value !== null) && is_array($filters)) {
|
||||
if (($value !== null) && is_array($filters)) {
|
||||
foreach (array_reverse($filters) as $filter) {
|
||||
$value = $this->decodeAttribute($filter, $value);
|
||||
$document->setAttribute($key, $value);
|
||||
|
@ -492,7 +492,7 @@ class Database
|
|||
*/
|
||||
static protected function encodeAttribute(string $name, $value)
|
||||
{
|
||||
if(!isset(self::$filters[$name])) {
|
||||
if (!isset(self::$filters[$name])) {
|
||||
throw new Exception('Filter not found');
|
||||
}
|
||||
|
||||
|
@ -513,7 +513,7 @@ class Database
|
|||
*/
|
||||
static protected function decodeAttribute(string $name, $value)
|
||||
{
|
||||
if(!isset(self::$filters[$name])) {
|
||||
if (!isset(self::$filters[$name])) {
|
||||
throw new Exception('Filter not found');
|
||||
}
|
||||
|
||||
|
|
|
@ -157,7 +157,7 @@ class Structure extends Validator
|
|||
foreach ($array as $key => $value) {
|
||||
$rule = $collection->search('key', $key, $rules);
|
||||
|
||||
if(!$rule) {
|
||||
if (!$rule) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ class UID extends Validator
|
|||
return false;
|
||||
}
|
||||
|
||||
if(mb_strlen($value) > 32) {
|
||||
if (mb_strlen($value) > 32) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -48,7 +48,7 @@ class Compose
|
|||
*/
|
||||
public function getService(string $name): Service
|
||||
{
|
||||
if(!isset($this->compose['services'][$name])) {
|
||||
if (!isset($this->compose['services'][$name])) {
|
||||
throw new Exception('Service not found');
|
||||
}
|
||||
|
||||
|
|
|
@ -16,15 +16,14 @@ class Env
|
|||
*/
|
||||
public function __construct(string $data)
|
||||
{
|
||||
|
||||
$data = explode("\n", $data);
|
||||
|
||||
foreach($data as &$row) {
|
||||
foreach ($data as &$row) {
|
||||
$row = explode('=', $row);
|
||||
$key = (isset($row[0])) ? trim($row[0]) : null;
|
||||
$value = (isset($row[1])) ? trim($row[1]) : null;
|
||||
|
||||
if($key) {
|
||||
if ($key) {
|
||||
$this->vars[$key] = $value;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -73,15 +73,15 @@ class PDOStatement extends PDOStatementNative
|
|||
$this->pdo = $this->pdo->reconnect();
|
||||
$this->PDOStatement = $this->pdo->prepare($this->PDOStatement->queryString, []);
|
||||
|
||||
foreach($this->values as $key => $set) {
|
||||
foreach ($this->values as $key => $set) {
|
||||
$this->PDOStatement->bindValue($key, $set['value'], $set['data_type']);
|
||||
}
|
||||
|
||||
foreach($this->params as $key => $set) {
|
||||
foreach ($this->params as $key => $set) {
|
||||
$this->PDOStatement->bindParam($key, $set['variable'], $set['data_type'], $set['length'], $set['driver_options']);
|
||||
}
|
||||
|
||||
foreach($this->columns as $key => $set) {
|
||||
foreach ($this->columns as $key => $set) {
|
||||
$this->PDOStatement->bindColumn($key, $set['param'], $set['type'], $set['maxlen'], $set['driverdata']);
|
||||
}
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ class CNAME extends Validator
|
|||
*/
|
||||
public function isValid($domain)
|
||||
{
|
||||
if(!is_string($domain)) {
|
||||
if (!is_string($domain)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -37,11 +37,11 @@ class Domain extends Validator
|
|||
*/
|
||||
public function isValid($value)
|
||||
{
|
||||
if(empty($value)) {
|
||||
if (empty($value)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!is_string($value)) {
|
||||
if (!is_string($value)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -99,7 +99,7 @@ class Origin extends Validator
|
|||
*/
|
||||
public function isValid($origin)
|
||||
{
|
||||
if(!is_string($origin)) {
|
||||
if (!is_string($origin)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ class FileName extends Validator
|
|||
return false;
|
||||
}
|
||||
|
||||
if(!is_string($name)) {
|
||||
if (!is_string($name)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ class FileSize extends Validator
|
|||
*/
|
||||
public function isValid($fileSize)
|
||||
{
|
||||
if(!is_int($fileSize)) {
|
||||
if (!is_int($fileSize)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ class Upload extends Validator
|
|||
*/
|
||||
public function isValid($path)
|
||||
{
|
||||
if(!is_string($path)) {
|
||||
if (!is_string($path)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@ class Files
|
|||
*/
|
||||
public static function removeMimeType(string $mimeType): void
|
||||
{
|
||||
if(isset(self::$mimeTypes[$mimeType])) {
|
||||
if (isset(self::$mimeTypes[$mimeType])) {
|
||||
unset(self::$mimeTypes[$mimeType]);
|
||||
}
|
||||
}
|
||||
|
@ -85,7 +85,7 @@ class Files
|
|||
*/
|
||||
public static function load(string $directory, string $root = null): void
|
||||
{
|
||||
if(!is_readable($directory)) {
|
||||
if (!is_readable($directory)) {
|
||||
throw new Exception('Failed to load directory: '.$directory);
|
||||
}
|
||||
|
||||
|
@ -106,7 +106,7 @@ class Files
|
|||
continue;
|
||||
}
|
||||
|
||||
if(substr($path, 0, 1) === '.') {
|
||||
if (substr($path, 0, 1) === '.') {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -127,7 +127,7 @@ class Files
|
|||
|
||||
closedir($handle);
|
||||
|
||||
if($directory === $root) {
|
||||
if ($directory === $root) {
|
||||
echo '[Static Files] Loadded '.self::$count.' files'.PHP_EOL;
|
||||
}
|
||||
}
|
||||
|
@ -139,7 +139,7 @@ class Files
|
|||
*/
|
||||
public static function isFileLoaded(string $uri): bool
|
||||
{
|
||||
if(!array_key_exists($uri, self::$loaded)) {
|
||||
if (!array_key_exists($uri, self::$loaded)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -153,7 +153,7 @@ class Files
|
|||
*/
|
||||
public static function getFileContents(string $uri): string
|
||||
{
|
||||
if(!array_key_exists($uri, self::$loaded)) {
|
||||
if (!array_key_exists($uri, self::$loaded)) {
|
||||
throw new Exception('File not found or not loaded: '.$uri);
|
||||
}
|
||||
|
||||
|
@ -167,7 +167,7 @@ class Files
|
|||
*/
|
||||
public static function getFileMimeType(string $uri): string
|
||||
{
|
||||
if(!array_key_exists($uri, self::$loaded)) {
|
||||
if (!array_key_exists($uri, self::$loaded)) {
|
||||
throw new Exception('File not found or not loaded: '.$uri);
|
||||
}
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ class Request extends UtopiaRequest
|
|||
*/
|
||||
public function getParam(string $key, $default = null)
|
||||
{
|
||||
switch($this->getMethod()) {
|
||||
switch ($this->getMethod()) {
|
||||
case self::METHOD_GET:
|
||||
return $this->getQuery($key, $default);
|
||||
break;
|
||||
|
@ -57,7 +57,7 @@ class Request extends UtopiaRequest
|
|||
*/
|
||||
public function getParams(): array
|
||||
{
|
||||
switch($this->getMethod()) {
|
||||
switch ($this->getMethod()) {
|
||||
case self::METHOD_GET:
|
||||
return (!empty($this->swoole->get)) ? $this->swoole->get : [];
|
||||
break;
|
||||
|
@ -143,7 +143,7 @@ class Request extends UtopiaRequest
|
|||
{
|
||||
$protocol = $this->getHeader('x-forwarded-proto', $this->getServer('server_protocol', 'https'));
|
||||
|
||||
if($protocol === 'HTTP/1.1') {
|
||||
if ($protocol === 'HTTP/1.1') {
|
||||
return 'http';
|
||||
}
|
||||
|
||||
|
@ -317,7 +317,7 @@ class Request extends UtopiaRequest
|
|||
break;
|
||||
}
|
||||
|
||||
if(empty($this->payload)) { // Make sure we return same data type even if json payload is empty or failed
|
||||
if (empty($this->payload)) { // Make sure we return same data type even if json payload is empty or failed
|
||||
$this->payload = [];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -54,7 +54,7 @@ class Response extends UtopiaResponse
|
|||
*/
|
||||
public function send(string $body = '', int $exit = null): void
|
||||
{
|
||||
if(!$this->disablePayload) {
|
||||
if (!$this->disablePayload) {
|
||||
$this->addHeader('X-Debug-Speed', (string)(microtime(true) - $this->startTime));
|
||||
|
||||
$this
|
||||
|
@ -67,13 +67,12 @@ class Response extends UtopiaResponse
|
|||
|
||||
$this->size = $this->size + strlen(implode("\n", $this->headers)) + $length;
|
||||
|
||||
if(array_key_exists(
|
||||
if (array_key_exists(
|
||||
$this->contentType,
|
||||
$this->compressed
|
||||
) && ($length <= $chunk)) { // Dont compress with GZIP / Brotli if header is not listed and size is bigger than 2mb
|
||||
$this->swoole->end($body);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
for ($i=0; $i < ceil($length / $chunk); $i++) {
|
||||
$this->swoole->write(substr($body, ($i * $chunk), min((($i * $chunk) + $chunk), $length)));
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ class Cron extends Validator
|
|||
*/
|
||||
public function isValid($value)
|
||||
{
|
||||
if(empty($value)) {
|
||||
if (empty($value)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -101,7 +101,7 @@ class Response extends UtopiaResponse
|
|||
*/
|
||||
public function getModel(string $key): Model
|
||||
{
|
||||
if(!isset($this->models[$key])) {
|
||||
if (!isset($this->models[$key])) {
|
||||
throw new Exception('Undefined model: '.$key);
|
||||
}
|
||||
|
||||
|
@ -126,23 +126,22 @@ class Response extends UtopiaResponse
|
|||
$model = $this->getModel($model);
|
||||
$output = [];
|
||||
|
||||
foreach($model->getRules() as $key => $rule) {
|
||||
if(!$document->isSet($key)) {
|
||||
if(!is_null($rule['default'])) {
|
||||
foreach ($model->getRules() as $key => $rule) {
|
||||
if (!$document->isSet($key)) {
|
||||
if (!is_null($rule['default'])) {
|
||||
$document->setAttribute($key, $rule['default']);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
throw new Exception('Missing response key: '.$key);
|
||||
}
|
||||
}
|
||||
|
||||
if($rule['array']) {
|
||||
if(!is_array($data[$key])) {
|
||||
if ($rule['array']) {
|
||||
if (!is_array($data[$key])) {
|
||||
throw new Exception($key.' must be an array of '.$rule['type'].' types');
|
||||
}
|
||||
|
||||
foreach ($data[$key] as &$item) {
|
||||
if(array_key_exists($rule['type'], $this->models) && $item instanceof Document) {
|
||||
if (array_key_exists($rule['type'], $this->models) && $item instanceof Document) {
|
||||
$item = $this->output($item, $rule['type']);
|
||||
}
|
||||
}
|
||||
|
@ -168,7 +167,7 @@ class Response extends UtopiaResponse
|
|||
*/
|
||||
public function yaml(array $data): void
|
||||
{
|
||||
if(!extension_loaded('yaml')) {
|
||||
if (!extension_loaded('yaml')) {
|
||||
throw new Exception('Missing yaml extension. Learn more at: https://www.php.net/manual/en/book.yaml.php');
|
||||
}
|
||||
|
||||
|
|
|
@ -9,7 +9,6 @@ class File extends Model
|
|||
{
|
||||
public function __construct()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue