forked from qpleple/cloudstack-php-client
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathObjectVariable.php
More file actions
111 lines (97 loc) · 2.64 KB
/
ObjectVariable.php
File metadata and controls
111 lines (97 loc) · 2.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
<?php declare(strict_types=1);
namespace MyENA\CloudStackClientGenerator\API;
use MyENA\CloudStackClientGenerator\Configuration\OverloadedClass;
/**
* Class ObjectVariable
* @package MyENA\CloudStackClientGenerator\API
*/
class ObjectVariable extends Variable
{
/** @var string */
private $namespace;
/** @var VariableContainer */
private $properties;
/** @var bool */
private $shared;
/** @var \MyENA\CloudStackClientGenerator\Configuration\OverloadedClass */
private $overloadedClass;
/**
* ObjectVariable constructor.
* @param bool $inResponse
* @param string $name
* @param string $namespace
* @param bool $shared
*/
public function __construct(bool $inResponse, string $name, string $namespace, bool $shared)
{
parent::__construct($inResponse, $name);
$this->namespace = $namespace;
$this->properties = new VariableContainer();
$this->shared = $shared;
}
/**
* @return \MyENA\CloudStackClientGenerator\Configuration\OverloadedClass|null
*/
public function getOverloadedClass(): ?OverloadedClass
{
return $this->overloadedClass ?? null;
}
/**
* @param \MyENA\CloudStackClientGenerator\Configuration\OverloadedClass|null $overloadedClass
*/
public function setOverloadedClass(?OverloadedClass $overloadedClass): void
{
$this->overloadedClass = $overloadedClass;
}
/**
* @return \MyENA\CloudStackClientGenerator\API\VariableContainer
*/
public function getProperties()
{
return $this->properties;
}
/**
* @return string
*/
public function getClassName(): string
{
if ($this->isShared()) {
return ucfirst($this->getName());
}
return ucfirst($this->getName()) . 'Response';
}
/**
* @return bool
*/
public function isShared(): bool
{
return $this->shared;
}
/**
* @inheritDoc
*/
public function getPHPType(): string
{
if ($overloaded = $this->getOverloadedClass()) {
return $overloaded->getFQName();
}
return $this->getFQName();
}
/**
* @return string
*/
public function getFQName(): string
{
if (!isset($this->namespace) || $this->namespace === '') {
return sprintf('\\CloudStackResponse\\%s', $this->getClassName());
}
return sprintf('\\%s\\CloudStackResponse\\%s', $this->namespace, $this->getClassName());
}
/**
* @return string
*/
public function getSwaggerName(): string
{
return "CloudStack{$this->getClassName()}";
}
}