コード例 #1
0
ファイル: ZoneMatcher.php プロジェクト: hd-deman/elcodi
 /**
  * @param ZoneInterface     $zone
  * @param ProvinceInterface $province
  *
  * @return boolean Province is contained in zone
  */
 public function isProvinceContainedInZone(ZoneInterface $zone, ProvinceInterface $province)
 {
     return $zone->getMembers()->filter(function (ZoneMemberInterface $zoneMember) {
         return $zoneMember instanceof ZoneProvinceMemberInterface;
     })->exists(function ($_, ZoneProvinceMemberInterface $zoneProvinceMember) use($province) {
         return $province->equals($zoneProvinceMember->getProvince());
     });
 }
コード例 #2
0
ファイル: City.php プロジェクト: hd-deman/elcodi
 /**
  * Get siblings
  *
  * @return Collection siblings
  */
 public function getSiblings()
 {
     return $this->province->getCities();
 }
コード例 #3
0
ファイル: Province.php プロジェクト: hd-deman/elcodi
 /**
  * Return if a province is equal than current
  *
  * @param ProvinceInterface $province Province to be compared with
  *
  * @return boolean Provinces are the same
  */
 public function equals(ProvinceInterface $province)
 {
     return $province->getId() === $this->getId();
 }
コード例 #4
0
ファイル: GeoBuilder.php プロジェクト: hd-deman/elcodi
 /**
  * Add a city with the premise that the province has to be added already
  *
  * @param ProvinceInterface $province Province
  * @param string            $cityName City name
  *
  * @return CityInterface
  */
 public function addCity(ProvinceInterface $province, $cityName)
 {
     $cityName = trim($cityName);
     $cityId = $province->getId() . '_' . preg_replace('/[^\\da-z]/i', '', strtolower($cityName));
     if (!isset($this->cities[$cityId])) {
         $city = $this->cityFactory->create();
         $city->setId($cityId)->setName($cityName)->setProvince($province)->setPostalCodes(new ArrayCollection())->setEnabled(true);
         $province->addCity($city);
         $this->cities[$cityId] = $city;
     }
     return $this->cities[$cityId];
 }