/**
  * @author Andreas Glaser
  */
 public function testStringStartsWith()
 {
     $this->assertTrue(StringHelper::startsWith($this->testString, 'Hello', true));
     $this->assertFalse(StringHelper::startsWith($this->testString, 'Hellu', true));
     $this->assertTrue(StringHelper::startsWith($this->testString, 'HELLO', false));
     // strings always "start" with null/nothing
     $this->assertTrue(StringHelper::startsWith($this->testString, null, true));
     $this->assertTrue(StringHelper::startsWith($this->testString, null, false));
 }
 /**
  * @param $entityClass
  *
  * @return null|string
  * @throws \Exception
  * @author Andreas Glaser
  */
 public static function get($entityClass)
 {
     $className = get_class($entityClass);
     // translate proxy classes
     if (StringHelper::startsWith($className, 'Proxies\\__CG__\\')) {
         $entityClass = substr($className, strlen('Proxies\\__CG__\\'));
     }
     $reader = new AnnotationReader();
     $apiMetaAnnotation = $reader->getClassAnnotation(new \ReflectionClass(new $entityClass()), 'AndreasGlaser\\DCEventBundle\\EventHandler\\Annotations\\DCEntityEventHandler');
     if (!$apiMetaAnnotation || !$apiMetaAnnotation->class) {
         return null;
     }
     if (!class_exists($apiMetaAnnotation->class)) {
         throw new \Exception(sprintf('DCEntityEventHandler class %s does not exist', $apiMetaAnnotation->class));
     }
     return $apiMetaAnnotation->class;
 }
 /**
  * Sets custom attribute.
  *
  * @param $name
  * @param $value
  *
  * @return $this
  *
  * @author Andreas Glaser
  */
 public function set($name, $value)
 {
     $name = mb_strtolower($name);
     if ($name === 'id') {
         $this->setId($value);
     } elseif ($name === 'class') {
         $this->addClass($value);
     } elseif ($name === 'style') {
         $pieces = explode(';', $value);
         foreach ($pieces as $definition) {
             $p = explode(':', $definition);
             if (isset($p[0]) && isset($p[1])) {
                 $this->addStyle($p[0], $p[1]);
             }
         }
     } elseif (StringHelper::startsWith('data-', $name)) {
         $this->addData(mb_substr($name, 5), $value);
     } else {
         $this->attributes[$name] = $value;
     }
     return $this;
 }