/** * Add state with the premise that the country has to be added already * * @param CountryInterface $country Country * @param string $stateCode State code * @param string $stateName State name * * @return StateInterface */ public function addState(CountryInterface $country, $stateCode, $stateName) { $stateCode = trim($stateCode); $stateName = trim($stateName); $stateId = $country->getCode() . '_' . $stateCode; if (!isset($this->states[$stateId])) { $state = $this->stateFactory->create(); $state->setId($stateId)->setCode($stateCode)->setName($stateName)->setCountry($country)->setProvinces(new ArrayCollection())->setEnabled(true); $country->addState($state); $this->states[$stateId] = $state; } return $this->states[$stateId]; }
/** * Return if a country is equal than current * * @param CountryInterface $country Country to be compared with * * @return boolean Countries are the same */ public function equals(CountryInterface $country) { return $country->getCode() === $this->getCode(); }
/** * Test the country entity * * @param CountryInterface $country Country * * @return $this Self Object */ public function blockTestCountry(CountryInterface $country) { $this->assertEquals('FR', $country->getCode()); return $this; }