src/Kunstmaan/AdminBundle/Helper/Security/Acl/Permission/MaskBuilder.php
public static function getCode($mask)
    {
        if (!is_int($mask)) {
            throw new InvalidArgumentException('$mask must be an integer.');
        }

        $reflection = new \ReflectionClass(get_called_class());
        foreach ($reflection->getConstants() as $name => $cMask) {
            if (0 !== strpos($name, 'MASK_')) {
                continue;
            }

            if ($mask === $cMask) {
                if (!defined($cName = 'static::CODE_'.substr($name, 5))) {
                    throw new \RuntimeException('There was no code defined for this mask.');
                }

                return constant($cName);
            }
        }

        throw new InvalidArgumentException(sprintf('The mask "%d" is not supported.', $mask));
    }
public static function getCode($mask)
    {
        if (!is_int($mask)) {
            throw new InvalidArgumentException('$mask must be an integer.');
        }

        $reflection = new \ReflectionClass(get_called_class());
        foreach ($reflection->getConstants() as $name => $cMask) {
            if (0 !== strpos($name, 'MASK_')) {
                continue;
            }

            if ($mask === $cMask) {
                if (!defined($cName = 'static::CODE_'.substr($name, 5))) {
                    throw new \RuntimeException('There was no code defined for this mask.');
                }

                return constant($cName);
            }
        }

        throw new InvalidArgumentException(sprintf('The mask "%d" is not supported.', $mask));
    }
public static function getCode ( $ mask ) { if ( ! is_int ( $ mask ) ) { throw new InvalidArgumentException ( '$mask must be an integer.' ) ; } $ reflection = new \ ReflectionClass ( get_called_class ( ) ) ; foreach ( $ reflection -> getConstants ( ) as $ name => $ cMask ) { if ( 0 !== strpos ( $ name , 'MASK_' ) ) { continue ; } if ( $ mask === $ cMask ) { if ( ! defined ( $ cName = 'static::CODE_' . substr ( $ name , 5 ) ) ) { throw new \ RuntimeException ( 'There was no code defined for this mask.' ) ; } return constant ( $ cName ) ; } } throw new InvalidArgumentException ( sprintf ( 'The mask "%d" is not supported.' , $ mask ) ) ; }
Returns the code for the passed mask

@param null|int $mask

@throws InvalidArgumentException
@throws \RuntimeException

@return string
Returns the code for the passed mask