217 lines
6.1 KiB
PHP
Executable File
217 lines
6.1 KiB
PHP
Executable File
<?php
|
|
/**
|
|
* Represents a facility in the EcoBuddy system
|
|
*
|
|
* This class serves as a data model for facilities, encapsulating all
|
|
* the properties and behaviours of a single facility. It follows the
|
|
* Data Transfer Object (DTO) pattern that I learned about in my
|
|
* software architecture module.
|
|
*
|
|
* Each facility has location data, descriptive information, and metadata
|
|
* about who contributed it. This class provides a clean interface for
|
|
* accessing this data throughout the application.
|
|
*/
|
|
class FacilityData {
|
|
/**
|
|
* Facility properties
|
|
*
|
|
* @var int $_id - Unique identifier for the facility
|
|
* @var string $_title - Name of the facility
|
|
* @var string $_category - Category/type of the facility
|
|
* @var string $_status - Current status of the facility
|
|
* @var string $_description - Detailed description of the facility
|
|
* @var string $_houseNumber - Building number or name
|
|
* @var string $_streetName - Street name
|
|
* @var string $_county - County
|
|
* @var string $_town - Town or city
|
|
* @var string $_postcode - Postal code
|
|
* @var float $_lng - Longitude coordinate
|
|
* @var float $_lat - Latitude coordinate
|
|
* @var string $_contributor - Username of the person who added the facility
|
|
*/
|
|
protected $_id;
|
|
protected $_title;
|
|
protected $_category;
|
|
protected $_status;
|
|
protected $_description;
|
|
protected $_houseNumber;
|
|
protected $_streetName;
|
|
protected $_county;
|
|
protected $_town;
|
|
protected $_postcode;
|
|
protected $_lng;
|
|
protected $_lat;
|
|
protected $_contributor;
|
|
|
|
/**
|
|
* Initialises a new facility with data from the database
|
|
* @param array $dbRow Database row containing facility data
|
|
*/
|
|
public function __construct($dbRow) {
|
|
$this->_id = $dbRow['id'];
|
|
$this->_title = $dbRow['title'];
|
|
$this->_category = $dbRow['category'];
|
|
$this->_status = $dbRow['status'];
|
|
$this->_description = $dbRow['description'];
|
|
$this->_houseNumber = $dbRow['houseNumber'];
|
|
$this->_streetName = $dbRow['streetName'];
|
|
$this->_county = $dbRow['county'];
|
|
$this->_town = $dbRow['town'];
|
|
$this->_postcode = $dbRow['postcode'];
|
|
$this->_lng = $dbRow['lng'];
|
|
$this->_lat = $dbRow['lat'];
|
|
$this->_contributor = $dbRow['contributor'];
|
|
}
|
|
|
|
/**
|
|
* Gets the facility's unique identifier
|
|
*
|
|
* This ID is used throughout the application to reference this specific
|
|
* facility, particularly in database operations and API requests.
|
|
*
|
|
* @return int The facility ID
|
|
*/
|
|
public function getId() {
|
|
return $this->_id;
|
|
}
|
|
|
|
/**
|
|
* Gets the facility's title
|
|
*
|
|
* The title is the primary name or label for the facility that
|
|
* is displayed to users in the interface.
|
|
*
|
|
* @return string The facility title
|
|
*/
|
|
public function getTitle() {
|
|
return $this->_title;
|
|
}
|
|
|
|
/**
|
|
* Gets the facility's category
|
|
*
|
|
* The category helps classify facilities by type, such as
|
|
* recycling centre, community garden, etc.
|
|
*
|
|
* @return string The facility category
|
|
*/
|
|
public function getCategory() {
|
|
return $this->_category;
|
|
}
|
|
|
|
/**
|
|
* Gets the facility's current status
|
|
*
|
|
* The status indicates whether the facility is operational,
|
|
* under maintenance, closed, etc.
|
|
*
|
|
* @return string The facility status
|
|
*/
|
|
public function getStatus() {
|
|
return $this->_status;
|
|
}
|
|
|
|
/**
|
|
* Gets the facility's description
|
|
*
|
|
* The description provides detailed information about the facility,
|
|
* its purpose, services offered, etc.
|
|
*
|
|
* @return string The facility description
|
|
*/
|
|
public function getDescription() {
|
|
return $this->_description;
|
|
}
|
|
|
|
/**
|
|
* Gets the facility's house/building number
|
|
*
|
|
* This is part of the facility's address and helps locate it physically.
|
|
*
|
|
* @return string The house/building number
|
|
*/
|
|
public function getHouseNumber() {
|
|
return $this->_houseNumber;
|
|
}
|
|
|
|
/**
|
|
* Gets the facility's street name
|
|
*
|
|
* This is part of the facility's address and helps locate it physically.
|
|
*
|
|
* @return string The street name
|
|
*/
|
|
public function getStreetName() {
|
|
return $this->_streetName;
|
|
}
|
|
|
|
/**
|
|
* Gets the facility's county
|
|
*
|
|
* This is part of the facility's address and helps locate it physically.
|
|
*
|
|
* @return string The county
|
|
*/
|
|
public function getCounty() {
|
|
return $this->_county;
|
|
}
|
|
|
|
/**
|
|
* Gets the facility's town or city
|
|
*
|
|
* This is part of the facility's address and helps locate it physically.
|
|
*
|
|
* @return string The town or city
|
|
*/
|
|
public function getTown() {
|
|
return $this->_town;
|
|
}
|
|
|
|
/**
|
|
* Gets the facility's postcode
|
|
*
|
|
* This is part of the facility's address and helps locate it physically.
|
|
* It's also useful for searching facilities by location.
|
|
*
|
|
* @return string The postcode
|
|
*/
|
|
public function getPostcode() {
|
|
return $this->_postcode;
|
|
}
|
|
|
|
/**
|
|
* Gets the facility's longitude coordinate
|
|
*
|
|
* This is used for displaying the facility on a map and
|
|
* for calculating distances between facilities.
|
|
*
|
|
* @return float The longitude coordinate
|
|
*/
|
|
public function getLng() {
|
|
return $this->_lng;
|
|
}
|
|
|
|
/**
|
|
* Gets the facility's latitude coordinate
|
|
*
|
|
* This is used for displaying the facility on a map and
|
|
* for calculating distances between facilities.
|
|
*
|
|
* @return float The latitude coordinate
|
|
*/
|
|
public function getLat() {
|
|
return $this->_lat;
|
|
}
|
|
|
|
/**
|
|
* Gets the username of the facility's contributor
|
|
*
|
|
* This tracks who added the facility to the system,
|
|
* which is useful for auditing and attribution.
|
|
*
|
|
* @return string The contributor's username
|
|
*/
|
|
public function getContributor() {
|
|
return $this->_contributor;
|
|
}
|
|
} |