|
- <?php
- if (!defined('DEDEINC')) exit('dedebiz');
- class Condition
- {
-
-
- public static function equal($value, $comparable)
- {
- return $value == $comparable;
- }
-
-
- public static function strictEqual($value, $comparable)
- {
- return $value === $comparable;
- }
-
-
- public static function notEqual($value, $comparable)
- {
- return $value != $comparable;
- }
-
-
- public static function strictNotEqual($value, $comparable)
- {
- return $value !== $comparable;
- }
-
-
- public static function greaterThan($value, $comparable)
- {
- return $value > $comparable;
- }
-
-
- public static function lessThan($value, $comparable)
- {
- return $value < $comparable;
- }
-
-
- public static function greaterThanOrEqual($value, $comparable)
- {
- return $value >= $comparable;
- }
-
-
- public static function lessThanOrEqual($value, $comparable)
- {
- return $value <= $comparable;
- }
-
-
- public static function in($value, $comparable)
- {
- return (is_array($comparable) && in_array($value, $comparable));
- }
-
-
- public static function notIn($value, $comparable)
- {
- return (is_array($comparable) && !in_array($value, $comparable));
- }
-
-
- public static function isNull($value, $comparable)
- {
- return is_null($value);
- }
-
-
- public static function isNotNull($value, $comparable)
- {
- return !is_null($value);
- }
-
-
- public static function startWith($value, $comparable)
- {
- if (is_array($comparable) || is_array($value) || is_object($comparable) || is_object($value)) {
- return false;
- }
- if (preg_match("/^$comparable/", $value)) {
- return true;
- }
- return false;
- }
-
-
- public static function endWith($value, $comparable)
- {
- if (is_array($comparable) || is_array($value) || is_object($comparable) || is_object($value)) {
- return false;
- }
- if (preg_match("/$comparable$/", $value)) {
- return true;
- }
- return false;
- }
-
-
- public static function match($value, $comparable)
- {
- if (is_array($comparable) || is_array($value) || is_object($comparable) || is_object($value)) {
- return false;
- }
- $comparable = trim($comparable);
- if (preg_match("/^$comparable$/", $value)) {
- return true;
- }
- return false;
- }
-
-
- public static function contains($value, $comparable)
- {
- return (strpos($value, $comparable) !== false);
- }
-
-
- public static function dateEqual($value, $comparable, $format = 'Y-m-d')
- {
- $date = date($format, strtotime($value));
- return $date == $comparable;
- }
-
-
- public static function monthEqual($value, $comparable)
- {
- $month = date('m', strtotime($value));
- return $month == $comparable;
- }
-
-
- public static function yearEqual($value, $comparable)
- {
- $year = date('Y', strtotime($value));
- return $year == $comparable;
- }
- }
- ?>
|