Add hub criteria object. #543
This commit is contained in:
parent
c970bd40e6
commit
09d04a8a7e
1 changed files with 103 additions and 0 deletions
103
src/Ramcar/HubCriteria.php
Normal file
103
src/Ramcar/HubCriteria.php
Normal file
|
|
@ -0,0 +1,103 @@
|
|||
<?php
|
||||
|
||||
namespace App\Ramcar;
|
||||
|
||||
use CrEOF\Spatial\PHP\Types\Geometry\Point;
|
||||
|
||||
use DateTime;
|
||||
|
||||
class HubCriteria
|
||||
{
|
||||
protected $point; // coordinates of source
|
||||
protected $limit_results; // number of results to return
|
||||
protected $limit_distance; // distance limit for search in km
|
||||
protected $has_inventory; // flag if we need to check for inventory
|
||||
protected $jo_type; // jo service needed
|
||||
protected $day_time; // day and time to check if hub is open or not
|
||||
protected $items; // array of items: items[id] = quantity to check for and has_inventory is true
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->has_inventory = false;
|
||||
$this->items = [];
|
||||
}
|
||||
|
||||
public function setPoint(Point $point)
|
||||
{
|
||||
$this->point = $point;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getPoint()
|
||||
{
|
||||
return $this->point;
|
||||
}
|
||||
|
||||
public function setLimitResults($limit_results)
|
||||
{
|
||||
$this->limit_results = $limit_results;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getLimitResults()
|
||||
{
|
||||
return $this->limit_results;
|
||||
}
|
||||
|
||||
public function setLimitDistance($limit_distance)
|
||||
{
|
||||
$this->limit_distance = $limit_distance;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getLimitDistance()
|
||||
{
|
||||
return $this->limit_distance;
|
||||
}
|
||||
|
||||
public function setHasInventory($has_inventory = true)
|
||||
{
|
||||
$this->has_inventory = $has_inventory;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function hasInventory()
|
||||
{
|
||||
return $this->has_inventory;
|
||||
}
|
||||
|
||||
public function setJoType($jo_type)
|
||||
{
|
||||
// TODO: validate the jo type
|
||||
$this->jo_type = $jo_type;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getJoType()
|
||||
{
|
||||
return $this->jo_type;
|
||||
}
|
||||
|
||||
public function setDayTime(DateTime $day_time)
|
||||
{
|
||||
$this->day_time = $day_time;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getDayTime()
|
||||
{
|
||||
return $this->day_time;
|
||||
}
|
||||
|
||||
public function addItem($id, $quantity)
|
||||
{
|
||||
// at this point, id is assumed to be a valid item
|
||||
$this->items[$id] = $quantity;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getItems()
|
||||
{
|
||||
return $this->items;
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue