diff options
author | AndreaChirulescu <andrea.chirulescu@gmail.com> | 2021-09-04 17:28:26 +0200 |
---|---|---|
committer | AndreaChirulescu <andrea.chirulescu@gmail.com> | 2021-09-04 17:28:26 +0200 |
commit | b92a2fc89ee23d20ac157fdf18e20861e6bd4c32 (patch) | |
tree | 9e998deb9a55df4b14a270cf78b097cd08753cf1 /includes/venue.php | |
parent | a479645ff6b092f72fa0add3dda6708214022200 (diff) | |
parent | 74fda7b89101ad47b77b486f4e38792db473cb00 (diff) | |
download | gigologadmin-b92a2fc89ee23d20ac157fdf18e20861e6bd4c32.tar.gz gigologadmin-b92a2fc89ee23d20ac157fdf18e20861e6bd4c32.tar.bz2 gigologadmin-b92a2fc89ee23d20ac157fdf18e20861e6bd4c32.zip |
Merge branch 'dev' of https://code.volse.net/wordpress/plugins/gigologadmin.git into andreaschanges
Diffstat (limited to 'includes/venue.php')
-rw-r--r-- | includes/venue.php | 35 |
1 files changed, 25 insertions, 10 deletions
diff --git a/includes/venue.php b/includes/venue.php index aedb6a7..3ad0f06 100644 --- a/includes/venue.php +++ b/includes/venue.php @@ -7,11 +7,19 @@ if ( !class_exists('GiglogAdmin_Venue') ) { class GiglogAdmin_Venue { - private $id; - private $name; - private $city; - private $address; - private $webpage; + private ?int $id; + + /** + * @psalm-suppress PropertyNotSetInConstructor + */ + private string $name; + + /** + * @psalm-suppress PropertyNotSetInConstructor + */ + private string $city; + private ?string $address; + private ?string $webpage; /* * Constructs a new venue object from an array of attributes. @@ -19,11 +27,19 @@ if ( !class_exists('GiglogAdmin_Venue') ) { * so this constructor can be used to construct the object * directly from the database row. */ - public function __construct($attrs) + public function __construct(object $attrs) { $this->id = isset($attrs->id) ? $attrs->id : NULL; - $this->name = isset($attrs->wpgvenue_name) ? $attrs->wpgvenue_name : NULL; - $this->city = isset($attrs->wpgvenue_city) ? $attrs->wpgvenue_city : NULL; + + if (isset($attrs->wpgvenue_name, $attrs->wpgvenue_city)) { + $this->name = $attrs->wpgvenue_name; + $this->city = $attrs->wpgvenue_city; + } + else { + error_log('Trying to construct a Venue without a name or a city'); + wp_die(); + } + $this->address = isset($attrs->wpgvenue_address) ? $attrs->wpgvenue_address : NULL; $this->webpage = isset($attrs->wpgvenue_webpage) ? $attrs->wpgvenue_webpage : NULL; } @@ -108,8 +124,7 @@ if ( !class_exists('GiglogAdmin_Venue') ) { static function venues_in_city(string $city): array { global $wpdb; - $q = $wpdb->prepare( - "select id, wpgvenue_name from wpg_venues where wpgvenue_city=%s", $city); + $q = $wpdb->prepare("select * from wpg_venues where wpgvenue_city=%s", $city); $results = $wpdb->get_results($q); return array_map(function ($r) { return new GiglogAdmin_Venue($r); }, $results); |