ManaPHP\Utility\Text::contains PHP Method

contains() public static method

public static contains ( string $haystack, string $needle, boolean $ignoreCase = false ) : boolean
$haystack string
$needle string
$ignoreCase boolean
return boolean
    public static function contains($haystack, $needle, $ignoreCase = false)
    {
        if ($ignoreCase) {
            return stripos($haystack, $needle) !== false;
        } else {
            return strpos($haystack, $needle) !== false;
        }
    }

Usage Example

Beispiel #1
0
 /**
  * Returns the mapped source for a model
  *
  * @param \ManaPHP\Mvc\ModelInterface|string $model
  *
  * @return string
  */
 public function getModelSource($model)
 {
     $modelName = is_string($model) ? $model : get_class($model);
     if (!isset($this->_sources[$modelName])) {
         if ($this->_recallGetModelSource) {
             return Text::underscore(Text::contains($modelName, '\\') ? substr($modelName, strrpos($modelName, '\\') + 1) : $modelName);
         }
         $modelInstance = is_string($model) ? new $model() : $model;
         /** @noinspection NotOptimalIfConditionsInspection */
         if (!isset($this->_sources[$modelName])) {
             $this->_recallGetModelSource = true;
             $this->_sources[$modelName] = $modelInstance->getSource();
             $this->_recallGetModelSource = false;
         }
     }
     return $this->_sources[$modelName];
 }
All Usage Examples Of ManaPHP\Utility\Text::contains