PageRenderTime 57ms CodeModel.GetById 7ms RepoModel.GetById 0ms app.codeStats 0ms

/vendor/symfony/security-acl/Util/ClassUtils.php

https://bitbucket.org/fanch1/testlb
PHP | 70 lines | 22 code | 10 blank | 38 comment | 2 complexity | 7283c56035181bcd3d1bc3cf287e10d4 MD5 | raw file
Possible License(s): BSD-3-Clause, Apache-2.0, BSD-2-Clause, GPL-2.0, GPL-3.0
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Component\Security\Acl\Util;
  11. use Doctrine\Common\Util\ClassUtils as DoctrineClassUtils;
  12. /**
  13. * Class related functionality for objects that
  14. * might or might not be proxy objects at the moment.
  15. *
  16. * @see DoctrineClassUtils
  17. *
  18. * @author Johannes Schmitt <schmittjoh@gmail.com>
  19. * @author Iltar van der Berg <kjarli@gmail.com>
  20. */
  21. final class ClassUtils
  22. {
  23. /**
  24. * Marker for Proxy class names.
  25. *
  26. * @var string
  27. */
  28. const MARKER = '__CG__';
  29. /**
  30. * Length of the proxy marker.
  31. *
  32. * @var int
  33. */
  34. const MARKER_LENGTH = 6;
  35. /**
  36. * This class should not be instantiated.
  37. */
  38. private function __construct()
  39. {
  40. }
  41. /**
  42. * Gets the real class name of a class name that could be a proxy.
  43. *
  44. * @param string|object $object
  45. *
  46. * @return string
  47. */
  48. public static function getRealClass($object)
  49. {
  50. $class = is_object($object) ? get_class($object) : $object;
  51. if (class_exists('Doctrine\Common\Util\ClassUtils')) {
  52. return DoctrineClassUtils::getRealClass($class);
  53. }
  54. // fallback in case doctrine common is not installed
  55. if (false === $pos = strrpos($class, '\\'.self::MARKER.'\\')) {
  56. return $class;
  57. }
  58. return substr($class, $pos + self::MARKER_LENGTH + 2);
  59. }
  60. }