-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 5dde418
Showing
15 changed files
with
1,009 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
|
||
namespace Bpa\ApiSandboxBundle\Annotation; | ||
|
||
/** | ||
* Class AbstractAnnotation | ||
*/ | ||
abstract class AbstractAnnotation | ||
{ | ||
/** | ||
* Response constructor. | ||
* | ||
* @param array $attributes | ||
*/ | ||
public function __construct(array $attributes) | ||
{ | ||
foreach ($attributes as $name => $attribute) { | ||
$setter = 'set'.ucfirst($name); | ||
|
||
if (method_exists($this, $setter)) { | ||
$this->$setter($attribute); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
<?php | ||
|
||
namespace Bpa\ApiSandboxBundle\Annotation; | ||
|
||
use Bpa\ApiSandboxBundle\Annotation\SandboxRequest\Parameter; | ||
use Doctrine\Common\Annotations\Annotation; | ||
|
||
/** | ||
* @Annotation | ||
* @Annotation\Target({"METHOD"}) | ||
* @Annotation\Attributes({ | ||
* @Annotation\Attribute("parameters", type="array<Bpa\ApiSandboxBundle\Annotation\SandboxRequest\Parameter>"), | ||
* @Annotation\Attribute("responses", type="array<Bpa\ApiSandboxBundle\Annotation\SandboxResponse>") | ||
* }) | ||
*/ | ||
class SandboxRequest extends AbstractAnnotation | ||
{ | ||
/** | ||
* @var array | ||
*/ | ||
private $parameters = []; | ||
|
||
/** | ||
* @var array | ||
*/ | ||
private $responses = []; | ||
|
||
/** | ||
* @param Parameter $parameter | ||
* | ||
* @return $this | ||
*/ | ||
public function addParameter(Parameter $parameter) | ||
{ | ||
if (!in_array($parameter, $this->parameters)) { | ||
$this->parameters[] = $parameter; | ||
} | ||
|
||
return $this; | ||
} | ||
|
||
/** | ||
* @return array|Parameter[] | ||
*/ | ||
public function getParameters() | ||
{ | ||
return $this->parameters; | ||
} | ||
|
||
/** | ||
* @param array $parameters | ||
* | ||
* @return $this | ||
*/ | ||
public function setParameters(array $parameters) | ||
{ | ||
$this->parameters = $parameters; | ||
|
||
return $this; | ||
} | ||
|
||
/** | ||
* @return array|SandboxResponse[] | ||
*/ | ||
public function getResponses() | ||
{ | ||
return $this->responses; | ||
} | ||
|
||
/** | ||
* @param array $responses | ||
* | ||
* @return $this | ||
*/ | ||
public function setResponses(array $responses) | ||
{ | ||
$this->responses = $responses; | ||
|
||
return $this; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,174 @@ | ||
<?php | ||
|
||
namespace Bpa\ApiSandboxBundle\Annotation\SandboxRequest; | ||
|
||
use Bpa\ApiSandboxBundle\Annotation\AbstractAnnotation; | ||
use Doctrine\Common\Annotations\Annotation; | ||
|
||
/** | ||
* @Annotation | ||
* @Annotation\Attributes({ | ||
* @Annotation\Attribute("name", type="string"), | ||
* @Annotation\Attribute("type", type=@Annotation\Enum({Parameter::TYPE_STRING, Parameter::TYPE_INTEGER, Parameter::TYPE_ARRAY})), | ||
* @Annotation\Attribute("required", type="boolean"), | ||
* @Annotation\Attribute("children", type="array<Parameter>"), | ||
* @Annotation\Attribute("value", type="mixed"), | ||
* @Annotation\Attribute("format", type="string"), | ||
* }) | ||
*/ | ||
class Parameter extends AbstractAnnotation | ||
{ | ||
const TYPE_STRING = 'string'; | ||
const TYPE_INTEGER = 'integer'; | ||
const TYPE_ARRAY = 'array'; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
private $name; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
private $type; | ||
|
||
/** | ||
* @var boolean | ||
*/ | ||
private $required; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
private $format; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
private $value; | ||
|
||
/** | ||
* @var array | ||
*/ | ||
private $children; | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getName() | ||
{ | ||
return $this->name; | ||
} | ||
|
||
/** | ||
* @param string $name | ||
* | ||
* @return $this | ||
*/ | ||
public function setName($name) | ||
{ | ||
$this->name = $name; | ||
|
||
return $this; | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getType() | ||
{ | ||
return $this->type; | ||
} | ||
|
||
/** | ||
* @param string $type | ||
* | ||
* @return $this | ||
*/ | ||
public function setType($type) | ||
{ | ||
$this->type = $type; | ||
|
||
return $this; | ||
} | ||
|
||
/** | ||
* @return bool | ||
*/ | ||
public function isRequired() | ||
{ | ||
return $this->required; | ||
} | ||
|
||
/** | ||
* @param bool $required | ||
* | ||
* @return $this | ||
*/ | ||
public function setRequired($required) | ||
{ | ||
$this->required = $required; | ||
|
||
return $this; | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getFormat() | ||
{ | ||
return $this->format; | ||
} | ||
|
||
/** | ||
* @param string $format | ||
* | ||
* @return $this | ||
*/ | ||
public function setFormat($format) | ||
{ | ||
$this->format = $format; | ||
|
||
return $this; | ||
} | ||
|
||
/** | ||
* @return mixed | ||
*/ | ||
public function getValue() | ||
{ | ||
return $this->value; | ||
} | ||
|
||
/** | ||
* @param mixed $value | ||
* | ||
* @return $this | ||
*/ | ||
public function setValue($value) | ||
{ | ||
$this->value = $value; | ||
|
||
return $this; | ||
} | ||
|
||
/** | ||
* @return array | ||
*/ | ||
public function getChildren() | ||
{ | ||
return $this->children; | ||
} | ||
|
||
/** | ||
* @param array $children | ||
* | ||
* @return $this | ||
*/ | ||
public function setChildren(array $children) | ||
{ | ||
$this->children = $children; | ||
|
||
return $this; | ||
} | ||
} |
Oops, something went wrong.