Beispiel #1
0
 /**
  * @dataProvider toSnakeCaseExceptionProvider
  *
  * @param string $camelCaseString
  *
  * @throws \Exception
  */
 public function testToSnakeCaseException($camelCaseString)
 {
     try {
         StringUtils::toSnakeCase($camelCaseString);
         $this->assertFalse(true, 'An exception should have been thrown.');
     } catch (Exception $exception) {
         $this->assertEquals('Unable to convert non string element.', $exception->getMessage());
     }
 }
Beispiel #2
0
 /**
  * @param string|object|null $class
  *
  * @return string|null
  *
  * @throws Exception
  */
 public static function getCanonicalName($class)
 {
     if (null === $class) {
         return;
     }
     $className = self::getClassFullQualifiedName($class);
     if (false !== strpos($className, '.')) {
         return $className;
     }
     return implode('.', array_map(function ($namespace) {
         return StringUtils::toSnakeCase($namespace, '_');
     }, explode('\\', $className)));
 }