[PHP] Made coding standard more consistent across template files

This commit is contained in:
Kim Sondrup
2016-05-13 01:47:59 +02:00
parent 6bb953d0aa
commit b2f5d8c060
9 changed files with 59 additions and 22 deletions

View File

@@ -55,18 +55,21 @@ class ApiClient
/**
* Configuration
*
* @var Configuration
*/
protected $config;
/**
* Object Serializer
*
* @var ObjectSerializer
*/
protected $serializer;
/**
* Constructor of the class
*
* @param Configuration $config config for this ApiClient
*/
public function __construct(\{{invokerPackage}}\Configuration $config = null)
@@ -81,6 +84,7 @@ class ApiClient
/**
* Get the config
*
* @return Configuration
*/
public function getConfig()
@@ -90,6 +94,7 @@ class ApiClient
/**
* Get the serializer
*
* @return ObjectSerializer
*/
public function getSerializer()
@@ -99,7 +104,9 @@ class ApiClient
/**
* Get API key (with prefix if set)
*
* @param string $apiKeyIdentifier name of apikey
*
* @return string API key with the prefix
*/
public function getApiKeyWithPrefix($apiKeyIdentifier)
@@ -122,12 +129,14 @@ class ApiClient
/**
* Make the HTTP call (Sync)
*
* @param string $resourcePath path to method endpoint
* @param string $method method to call
* @param array $queryParams parameters to be place in query URL
* @param array $postData parameters to be placed in POST body
* @param array $headerParams parameters to be place in request header
* @param string $responseType expected response type of the endpoint
*
* @throws \{{invokerPackage}}\ApiException on a non 2xx response
* @return mixed
*/
@@ -171,7 +180,7 @@ class ApiClient
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0);
}
if (! empty($queryParams)) {
if (!empty($queryParams)) {
$url = ($url . '?' . http_build_query($queryParams));
}
@@ -216,7 +225,7 @@ class ApiClient
// Make the request
$response = curl_exec($curl);
$http_header_size = curl_getinfo($curl, CURLINFO_HEADER_SIZE);
$http_header = $this->http_parse_headers(substr($response, 0, $http_header_size));
$http_header = $this->httpParseHeaders(substr($response, 0, $http_header_size));
$http_body = substr($response, $http_header_size);
$response_info = curl_getinfo($curl);
@@ -295,7 +304,7 @@ class ApiClient
*
* @return string[] Array of HTTP response heaers
*/
protected function http_parse_headers($raw_headers)
protected function httpParseHeaders($raw_headers)
{
// ref/credit: http://php.net/manual/en/function.http-parse-headers.php#112986
$headers = array();

View File

@@ -48,24 +48,28 @@ class ApiException extends Exception
/**
* The HTTP body of the server response either as Json or string.
*
* @var mixed
*/
protected $responseBody;
/**
* The HTTP header of the server response.
*
* @var string[]
*/
protected $responseHeaders;
/**
* The deserialized response object
*
* @var $responseObject;
*/
protected $responseObject;
/**
* Constructor
*
* @param string $message Error message
* @param int $code HTTP status code
* @param string $responseHeaders HTTP response header
@@ -100,7 +104,9 @@ class ApiException extends Exception
/**
* Sets the deseralized response object (during deserialization)
*
* @param mixed $obj Deserialized response object
*
* @return void
*/
public function setResponseObject($obj)

View File

@@ -52,12 +52,14 @@ use \{{invokerPackage}}\ObjectSerializer;
/**
* API Client
*
* @var \{{invokerPackage}}\ApiClient instance of the ApiClient
*/
protected $apiClient;
/**
* Constructor
*
* @param \{{invokerPackage}}\ApiClient|null $apiClient The api client to use
*/
function __construct(\{{invokerPackage}}\ApiClient $apiClient = null)
@@ -72,6 +74,7 @@ use \{{invokerPackage}}\ObjectSerializer;
/**
* Get API client
*
* @return \{{invokerPackage}}\ApiClient get the API client
*/
public function getApiClient()
@@ -81,7 +84,9 @@ use \{{invokerPackage}}\ObjectSerializer;
/**
* Set the API client
*
* @param \{{invokerPackage}}\ApiClient $apiClient set the API client
*
* @return {{classname}}
*/
public function setApiClient(\{{invokerPackage}}\ApiClient $apiClient)
@@ -92,28 +97,30 @@ use \{{invokerPackage}}\ObjectSerializer;
{{#operation}}
/**
* {{{operationId}}}
* Operation {{{operationId}}}
*
* {{{summary}}}
*
{{#allParams}} * @param {{dataType}} ${{paramName}} {{description}} {{#required}}(required){{/required}}{{^required}}(optional{{#defaultValue}}, default to {{{.}}}{{/defaultValue}}){{/required}}
{{/allParams}} * @return {{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/returnType}}
{{/allParams}} *
* @return {{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/returnType}}
* @throws \{{invokerPackage}}\ApiException on non-2xx response
*/
public function {{operationId}}({{#allParams}}${{paramName}}{{^required}} = null{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}})
{
list($response) = $this->{{operationId}}WithHttpInfo ({{#allParams}}${{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}});
list($response) = $this->{{operationId}}WithHttpInfo({{#allParams}}${{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}});
return $response;
}
/**
* {{{operationId}}}WithHttpInfo
* Operation {{{operationId}}}WithHttpInfo
*
* {{{summary}}}
*
{{#allParams}} * @param {{dataType}} ${{paramName}} {{description}} {{#required}}(required){{/required}}{{^required}}(optional{{#defaultValue}}, default to {{{.}}}{{/defaultValue}}){{/required}}
{{/allParams}} * @return Array of {{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}null{{/returnType}}, HTTP status code, HTTP response headers (array of strings)
{{/allParams}} *
* @return Array of {{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}null{{/returnType}}, HTTP status code, HTTP response headers (array of strings)
* @throws \{{invokerPackage}}\ApiException on non-2xx response
*/
public function {{operationId}}WithHttpInfo({{#allParams}}${{paramName}}{{^required}} = null{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}})

View File

@@ -53,14 +53,16 @@ use \{{invokerPackage}}\ObjectSerializer;
/**
* Setup before running each test case
*/
public static function setUpBeforeClass() {
public static function setUpBeforeClass()
{
}
/**
* Clean up after running each test case
*/
public static function tearDownAfterClass() {
public static function tearDownAfterClass()
{
}
@@ -71,7 +73,8 @@ use \{{invokerPackage}}\ObjectSerializer;
* {{{summary}}}
*
*/
public function test_{{operationId}}() {
public function test_{{operationId}}()
{
}
{{/operation}}

View File

@@ -9,6 +9,7 @@
* new \{{invokerPackage}}\Baz\Qux;
*
* @param string $class The fully-qualified class name.
*
* @return void
*/
spl_autoload_register(function ($class) {

View File

@@ -103,7 +103,8 @@ class {{classname}} {{#parentSchema}}extends {{{parent}}} {{/parentSchema}}imple
{{/hasMore}}{{/vars}}
);
static function getters() {
static function getters()
{
return {{#parentSchema}}parent::getters() + {{/parentSchema}}self::$getters;
}
@@ -115,7 +116,8 @@ class {{classname}} {{#parentSchema}}extends {{{parent}}} {{/parentSchema}}imple
* Gets allowable values of the enum
* @return string[]
*/
public function {{getter}}AllowableValues() {
public function {{getter}}AllowableValues()
{
return [
{{#allowableValues}}{{#enumVars}}self::{{datatypeWithEnum}}_{{{name}}},{{^-last}}
{{/-last}}{{/enumVars}}{{/allowableValues}}

View File

@@ -7,7 +7,8 @@ class {{classname}} {
* Gets allowable values of the enum
* @return string[]
*/
public function {{getter}}AllowableValues() {
public function {{getter}}AllowableValues()
{
return [
{{#allowableValues}}{{#enumVars}}self::{{datatypeWithEnum}}_{{{name}}},{{^-last}}
{{/-last}}{{/enumVars}}{{/allowableValues}}

View File

@@ -9,7 +9,8 @@ class {{classname}} {{#parent}}extends {{{parent}}} {{/parent}}implements ArrayA
{{/hasMore}}{{/vars}}
);
static function swaggerTypes() {
static function swaggerTypes()
{
return self::$swaggerTypes{{#parent}} + parent::swaggerTypes(){{/parent}};
}
@@ -22,7 +23,8 @@ class {{classname}} {{#parent}}extends {{{parent}}} {{/parent}}implements ArrayA
{{/hasMore}}{{/vars}}
);
static function attributeMap() {
static function attributeMap()
{
return {{#parent}}parent::attributeMap() + {{/parent}}self::$attributeMap;
}
@@ -35,7 +37,8 @@ class {{classname}} {{#parent}}extends {{{parent}}} {{/parent}}implements ArrayA
{{/hasMore}}{{/vars}}
);
static function setters() {
static function setters()
{
return {{#parent}}parent::setters() + {{/parent}}self::$setters;
}
@@ -48,7 +51,8 @@ class {{classname}} {{#parent}}extends {{{parent}}} {{/parent}}implements ArrayA
{{/hasMore}}{{/vars}}
);
static function getters() {
static function getters()
{
return {{#parent}}parent::getters() + {{/parent}}self::$getters;
}
@@ -60,7 +64,8 @@ class {{classname}} {{#parent}}extends {{{parent}}} {{/parent}}implements ArrayA
* Gets allowable values of the enum
* @return string[]
*/
public function {{getter}}AllowableValues() {
public function {{getter}}AllowableValues()
{
return [
{{#allowableValues}}{{#enumVars}}self::{{datatypeWithEnum}}_{{{name}}},{{^-last}}
{{/-last}}{{/enumVars}}{{/allowableValues}}

View File

@@ -51,21 +51,24 @@ class {{classname}}Test extends \PHPUnit_Framework_TestCase
/**
* Setup before running each test case
*/
public static function setUpBeforeClass() {
public static function setUpBeforeClass()
{
}
/**
* Clean up after running each test case
*/
public static function tearDownAfterClass() {
public static function tearDownAfterClass()
{
}
/**
* Test {{classname}}
*/
public function test{{classname}}() {
public function test{{classname}}()
{
}