for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/*
* Copyright (c) Nate Brunette.
* Distributed under the MIT License (http://opensource.org/licenses/MIT)
*/
declare(strict_types=1);
namespace Tebru\Gson\Annotation;
use RuntimeException;
use Tebru\AnnotationReader\AbstractAnnotation;
/**
* Class Accessor
*
* Use this annotation to explicitly define a getter/setter method mapping
* @author Nate Brunette <[email protected]>
* @Annotation
* @Target({"PROPERTY"})
class Accessor extends AbstractAnnotation
{
* Method name representing getter
* @var string
private $get;
* Method name representing setter
private $set;
* Constructor
* @throws RuntimeException
protected function init(): void
$this->get = $this->data['get'] ?? null;
$this->set = $this->data['set'] ?? null;
if (null === $this->get && null === $this->set) {
throw new RuntimeException('@Accessor annotation must specify either get or set key');
}
* A method name representing the getter
* @return string
public function getter(): ?string
return $this->get;
* A method name representing the setter
public function setter(): ?string
return $this->set;