Ouzo\Utilities\Strings::contains PHP Method

contains() public static method

Checks if string contains the substring.
public static contains ( string $string, string $substring ) : boolean
$string string
$substring string
return boolean
    public static function contains($string, $substring)
    {
        return mb_strpos($string, $substring) !== false;
    }

Usage Example

Beispiel #1
0
 public function getMetadata($instance)
 {
     $class = new ReflectionClass($instance);
     $properties = $class->getProperties();
     $annotations = array();
     foreach ($properties as $property) {
         $doc = $property->getDocComment();
         if (Strings::contains($doc, '@Inject')) {
             if (preg_match("#@var ([\\\\A-Za-z0-9]*)#s", $doc, $matched)) {
                 $className = $matched[1];
                 $name = $this->extractName($doc);
                 $annotations[$property->getName()] = array('name' => $name, 'className' => $className);
             } else {
                 throw new InjectorException('Cannot @Inject dependency. @var is not defined for property $' . $property->getName() . ' in class ' . $class->getName() . '.');
             }
         }
     }
     return $annotations;
 }
All Usage Examples Of Ouzo\Utilities\Strings::contains