1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94
<?php
namespace SIW\Data;
/**
* Bevat informatie over een continent
*
* @copyright 2019 SIW Internationale Vrijwilligersprojecten
* @since 3.0.0
*/
class Continent {
/**
* Slug van continent
*
* @var string
*/
protected $slug;
/**
* Naam van het continent
*
* @var string
*/
protected $name;
/**
* Kleurcode van continent op kaart
*
* @var string
*/
protected $color;
/**
* Constructor
*/
public function __construct( array $continent ) {
$defaults = [
'slug' => '',
'name' => '',
'color' => '',
];
$continent = wp_parse_args( $continent, $defaults );
$this->slug = $continent['slug'];
$this->name = $continent['name'];
$this->color = $continent['color'];
}
/**
* Geeft de slug van het continent terug
*
* @return string
*/
public function get_slug() {
return $this->slug;
}
/**
* Geeft de naam van het continent terug
*
* @return string
*/
public function get_name() {
return $this->name;
}
/**
* Geeft kleurcode van continent op kaart terug
*
* @return string
*/
public function get_color() {
return $this->color;
}
/**
* Geeft landen van dit continent op
*
* @return \SIW\Data\Country[]
*
* @todo hoort dit wel hier
* @todo caching
*/
public function get_countries() {
$countries = \siw_get_countries();
return array_filter(
$countries,
function( $country) {
return $country->get_continent()->get_slug() == $this->slug;
}
);
}
}