for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/*
* This file is part of the Slince/China package.
*
* (c) Slince <[email protected]>
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace China\Region\Location;
use Doctrine\Common\Collections\Collection;
abstract class Address implements AddressInterface
{
/**
* @var string
protected $code;
protected $name;
* @var AddressInterface
protected $parent;
* 子地区
* @var AddressInterface[]|Collection
protected $children;
public function __construct($code, $name, AddressInterface $parent = null)
$this->code = $code;
$this->name = $name;
$this->parent = $parent;
}
* {@inheritdoc}
public function getName()
return $this->name;
public function getCode()
return $this->code;
public function __toString()
return $this->getName();
public function setParent(AddressInterface $parent)
public function getParent()
return $this->parent;
public function setChildren($children)
$this->children = $children;
public function getChildren()
return $this->children;
public function jsonSerialize()
return [
'code' => $this->code,
'name' => $this->name,
'type' => static::getType(),
'children' => $this->getChildren()
];
* 获取当前类类型
* @return string
public static function getType()
return '';