use proper namespaces, getters/setters, and phpdocs

This commit is contained in:
nmonterroso 2015-06-18 15:41:12 -07:00
parent 4495774fd5
commit bb11322919
6 changed files with 54 additions and 33 deletions

View File

@ -15,7 +15,7 @@
* limitations under the License.
*/
namespace {{invokerPackage}};
namespace {{invokerNamespace}};
class ApiClient {

View File

@ -15,7 +15,7 @@
* limitations under the License.
*/
namespace {{invokerPackage}};
namespace {{invokerNamespace}};
use \Exception;

View File

@ -20,11 +20,17 @@
* NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually.
*/
namespace {{invokerPackage}};
namespace {{apiNamespace}};
use {{invokerNamespace}}\Configuration;
use {{invokerNamespace}}\ApiClient;
{{#operations}}
class {{classname}} {
/** @var ApiClient */
private $apiClient;
function __construct($apiClient = null) {
if (null === $apiClient) {
if (Configuration::$apiClient === null) {
@ -38,8 +44,6 @@ class {{classname}} {
}
}
private $apiClient; // instance of the ApiClient
/**
* get the API client
*/

View File

@ -1,29 +1,29 @@
<?php
spl_autoload_register(function ($class) {
// project-specific namespace prefix
$prefix = '{{rootNamespace}}\\';
// project-specific namespace prefix
$prefix = '{{rootNamespace}}\\';
// base directory for the namespace prefix
$base_dir = __DIR__ . '/src/';
// base directory for the namespace prefix
$base_dir = __DIR__ . '/src/';
// does the class use the namespace prefix?
$len = strlen($prefix);
if (strncmp($prefix, $class, $len) !== 0) {
// no, move to the next registered autoloader
return;
}
// does the class use the namespace prefix?
$len = strlen($prefix);
if (strncmp($prefix, $class, $len) !== 0) {
// no, move to the next registered autoloader
return;
}
// get the relative class name
$relative_class = substr($class, $len);
// get the relative class name
$relative_class = substr($class, $len);
// replace the namespace prefix with the base directory, replace namespace
// separators with directory separators in the relative class name, append
// with .php
$file = $base_dir . str_replace('\\', '/', $relative_class) . '.php';
// replace the namespace prefix with the base directory, replace namespace
// separators with directory separators in the relative class name, append
// with .php
$file = $base_dir . str_replace('\\', '/', $relative_class) . '.php';
// if the file exists, require it
if (file_exists($file)) {
require $file;
}
// if the file exists, require it
if (file_exists($file)) {
require $file;
}
});

View File

@ -15,7 +15,7 @@
* limitations under the License.
*/
namespace {{invokerPackage}};
namespace {{invokerNamespace}};
class Configuration {

View File

@ -24,7 +24,7 @@
*
*/
namespace {{invokerPackage}}\models;
namespace {{modelNamespace}};
use \ArrayAccess;
@ -39,17 +39,34 @@ class {{classname}} implements ArrayAccess {
{{/hasMore}}{{/vars}}
);
{{#vars}}{{#description}}
/**
* {{{description}}}
*/{{/description}}
public ${{name}}; /* {{{datatype}}} */{{/vars}}
{{#vars}}
/**{{#description}}
* {{{description}}}{{/description}}
* @var {{{datatype}}}
*/
public ${{name}};
{{/vars}}
public function __construct(array $data = null) {
{{#vars}}$this->{{name}} = $data["{{name}}"];{{#hasMore}}
{{/hasMore}}{{/vars}}
}
{{#vars}}
/**
* get {{name}}
* @return {{datatype}}
*/
public function {{getter}}() {
return $this->{{name}};
}
/**
* set {{name}}
* @param {{datatype}} ${{name}}
*/
public function {{setter}}(${{name}}) {
$this->{{name}} = ${{name}};
}
{{/vars}}
public function offsetExists($offset) {
return isset($this->$offset);
}