/**
  * Return the countries as array with objects.
  *
  * <code>
  * $options = array(
  *     "ids" => array(1,2,3,4,5)
  * );
  *
  * $countries   = new Crowdfunding\Country\Countries(\JFactory::getDbo());
  * $countries->load($options);
  *
  * $countries = $countries->getCountries();
  * </code>
  *
  * @return array
  */
 public function getCountries()
 {
     $results = array();
     $i = 0;
     foreach ($this->items as $item) {
         $country = new Country($this->db);
         $country->bind($item);
         $results[$i] = $country;
         $i++;
     }
     return $results;
 }
示例#2
0
 /**
  * Create a country object and return it.
  *
  * <code>
  * $options = array(
  *     "ids" => array(1,2,3,4,5)
  * );
  *
  * $countries   = new Crowdfunding\Country\Countries(\JFactory::getDbo());
  * $countries->load($options);
  *
  * $countryId = 1;
  * $country   = $countries->getCountry($countryId);
  * </code>
  *
  * @param int|string $id Country ID or Country code.
  *
  * @return null|Country
  */
 public function getCountry($id)
 {
     if (!$id) {
         throw new \UnexpectedValueException(\JText::_('LIB_CROWDFUNDING_INVALID_COUNTRY_ID'));
     }
     $country = null;
     foreach ($this->items as $item) {
         if (is_numeric($id) and (int) $item['id'] === (int) $id) {
             $country = new Country($this->db);
             $country->bind($item);
             break;
         } elseif (strcmp($id, $item['code']) === 0) {
             $country = new Country($this->db);
             $country->bind($item);
             break;
         }
     }
     return $country;
 }