Add generic NameValue class for name value pair collections

This commit is contained in:
Kendrick Chan 2018-01-31 13:17:55 +08:00
parent d0d0c04c5d
commit 196850f7b6
2 changed files with 20 additions and 15 deletions

View file

@ -2,7 +2,7 @@
namespace App\Ramcar;
class JOStatus
class JOStatus extends NameValue
{
const PENDING = 'pending';
const RIDER_ASSIGN = 'rider_assign';
@ -19,18 +19,4 @@ class JOStatus
'cancelled' => 'Cancelled',
'fulfilled' => 'Fulfilled',
];
static public function getCollection()
{
return self::COLLECTION;
}
static public function validate($type_text)
{
if (isset(self::COLLECTION[$type_text]))
return true;
return false;
}
}

19
src/Ramcar/NameValue.php Normal file
View file

@ -0,0 +1,19 @@
<?php
namespace App\Ramcar;
class NameValue
{
static public function getCollection()
{
return static::COLLECTION;
}
static public function validate($type_text)
{
if (isset(static::COLLECTION[$type_text]))
return true;
return false;
}
}