コード例 #1
0
ファイル: ToolKit.php プロジェクト: bluesnowman/Chimera
 /**
  * This method returns whether the specified value is "empty" (i.e. "null", "undefined", or a string
  * of length "0").
  *
  * @access public
  * @static
  * @param mixed $value                                      the value to be evaluated
  * @return boolean                                          whether the value is "empty"
  */
 public static function isEmpty($value)
 {
     return $value === null || Core\Data\Undefined::instance()->__equals($value) || Common\String::isTypeOf($value) && $value == '';
 }
コード例 #2
0
ファイル: Currency.php プロジェクト: bluesnowman/Chimera
 /**
  * This method returns ISO data for the specified currency.
  *
  * @access protected
  * @param string $currency                                  the currency to be queried
  * @return array                                            the data
  */
 protected function getCurrencyData($currency)
 {
     if (is_string($currency) || is_integer($currency)) {
         $currency = Core\Convert::toString($currency);
         $currency = preg_replace('/\\s+/', ' ', trim($currency));
         $length = strlen($currency);
         if ($length == 3) {
             $records = DB\SQL::select('locale')->from('Currencies')->where('CurrencyNumeric3', '=', $currency)->where('CurrencyAlpha3', '=', strtoupper($currency), 'OR')->limit(1)->query();
             if ($records->is_loaded()) {
                 return $records->current();
             }
         } else {
             $records = DB\SQL::select('locale')->before(function (DB\Connection\Driver $driver) {
                 $driver->get_resource()->createFunction('TRANSLITERATE', function ($string) {
                     return Common\String::transliterate($string)->__toString();
                 }, 1);
             })->from('Currencies')->where(DB\SQL::expr('LOWER([CurrencyName])'), '=', strtolower($currency))->where(DB\SQL::expr("LOWER(TRANSLITERATE([CurrencyName]))"), '=', Common\String::transliterate($currency)->toLowerCase()->__toString(), 'OR')->where(DB\SQL::expr('LOWER([CurrencySymbol])'), '=', strtolower($currency))->limit(1)->query();
             if ($records->is_loaded()) {
                 return $records->current();
             }
             $records = DB\SQL::select('locale')->before(function (DB\Connection\Driver $driver) {
                 $driver->get_resource()->createFunction('PREG_REPLACE', 'preg_replace', 3);
             })->from('Currencies')->where(DB\SQL::expr("LOWER(PREG_REPLACE('/[^a-z]/i', '', [CurrencyName]))"), '=', strtolower(preg_replace('/[^a-z]/i', '', $currency)))->limit(1)->query();
             if ($records->is_loaded()) {
                 return $records->current();
             }
             $records = DB\SQL::select('locale')->before(function (DB\Connection\Driver $driver) {
                 $driver->get_resource()->createFunction('TRANSLITERATE', function ($string) {
                     return Common\String::transliterate($string)->__toString();
                 }, 1);
             })->from('Currencies')->where(DB\SQL::expr('LOWER([CurrencyName])'), 'LIKE', '%' . strtolower($currency) . '%')->where(DB\SQL::expr("LOWER(TRANSLITERATE([CurrencyName]))"), 'LIKE', '%' . Common\String::transliterate($currency)->toLowerCase() . '%', 'OR')->limit(1)->query();
             if ($records->is_loaded()) {
                 return $records->current();
             }
             $records = DB\SQL::select('locale')->before(function (DB\Connection\Driver $driver) {
                 $driver->get_resource()->createFunction('SOUNDEX', 'soundex', 1);
             })->from('Currencies')->where(DB\SQL::expr("SOUNDEX([CurrencyName])"), '=', DB\SQL::expr("SOUNDEX('{$currency}')"))->limit(1)->query();
             if ($records->is_loaded()) {
                 return $records->current();
             }
         }
     }
     return array('CurrencyID' => 0, 'CurrencyName' => null, 'CurrencyNumeric3' => null, 'CurrencyAlpha3' => null, 'CurrencySymbol' => null, 'CurrencyDecimals' => -1);
 }
コード例 #3
0
ファイル: Item.php プロジェクト: bluesnowman/Chimera
 /**
  * This method return a new object with the transliterated value.
  *
  * @access public
  * @return MappingService\Data\Field\Item                   a new object with the transliterated
  *                                                          value
  *
  */
 public function transliterate()
 {
     if ($this->info->type == 'string') {
         $value = Common\String::transliterate($this->value)->__toString();
         return static::factory($this->name, $value);
     }
     return $this;
 }
コード例 #4
0
ファイル: File.php プロジェクト: bluesnowman/Chimera
 /**
  * This constructor initializes the class with the specified URI.
  *
  * @access public
  * @param string $uri                                       the URI to the file
  * @throws Throwable\InvalidArgument\Exception              indicates a data type mismatch
  */
 public function __construct($uri)
 {
     $this->name = null;
     $this->path = null;
     $this->ext = null;
     if (!Common\String::isTypeOf($uri)) {
         throw new Throwable\InvalidArgument\Exception('Unable to handle argument. Argument must be a string, but got :type.', array(':type' => gettype($uri)));
     }
     $this->uri = preg_replace('/^classpath:/i', Bootstrap::rootPath(), $uri, 1);
     $this->temporary = false;
 }