1
0
Fork 0
mirror of synced 2024-07-07 15:36:19 +12:00
appwrite/src/Appwrite/Specification/Format.php

101 lines
1.9 KiB
PHP
Raw Normal View History

2020-11-12 11:02:42 +13:00
<?php
namespace Appwrite\Specification;
use Utopia\App;
use Utopia\Route;
use Appwrite\Utopia\Response\Model;
abstract class Format
{
protected App $app;
2022-05-24 02:54:50 +12:00
2020-11-12 11:02:42 +13:00
/**
* @var Route[]
*/
protected array $routes;
2022-05-24 02:54:50 +12:00
2020-11-12 11:02:42 +13:00
/**
* @var Model[]
*/
protected array $models;
2022-05-24 02:54:50 +12:00
protected array $services;
protected array $keys;
protected int $authCount;
protected array $params = [
2020-11-12 11:02:42 +13:00
'name' => '',
'description' => '',
'endpoint' => 'https://localhost',
'version' => '1.0.0',
'terms' => '',
'support.email' => '',
'support.url' => '',
'contact.name' => '',
'contact.email' => '',
'contact.url' => '',
'license.name' => '',
'license.url' => '',
];
public function __construct(App $app, array $services, array $routes, array $models, array $keys, int $authCount)
2020-11-12 11:02:42 +13:00
{
$this->app = $app;
$this->services = $services;
2020-11-12 11:02:42 +13:00
$this->routes = $routes;
$this->models = $models;
$this->keys = $keys;
2021-05-20 02:26:06 +12:00
$this->authCount = $authCount;
2020-11-12 11:02:42 +13:00
}
/**
* Get Name.
*
* Get format name
*
* @return string
*/
abstract public function getName(): string;
/**
* Parse
*
* Parses Appwrite App to given format
*
* @return array
*/
abstract public function parse(): array;
/**
* Set Param.
*
* Set param value
*
* @param string $key
* @param string $value
2022-05-24 02:54:50 +12:00
*
2020-11-12 11:02:42 +13:00
* @return self
*/
public function setParam(string $key, string $value): self
{
$this->params[$key] = $value;
return $this;
}
/**
* Get Param.
*
* Get param value
*
* @param string $key
* @param string $default
2022-05-24 02:54:50 +12:00
*
2020-11-12 11:02:42 +13:00
* @return string
*/
public function getParam(string $key, string $default = ''): string
{
return $this->params[$key] ?? $default;
2020-11-12 11:02:42 +13:00
}
}