Get a masked instance by providing a mask name
@param string|null $mask

@return mixed
@throws MaskNotFoundException
964486
public function mask($mask = null){
        $mask = $mask !== null ? $mask : $this->mask;
        if(class_exists($mask)){
            return new $mask($this);
        }

        throw new MaskNotFoundException("Unknown mask provided: ".$mask);
    }
1082810
public function evalFilterMask($mask) {
        // string masks
        if (is_string($mask)) {
            if (strpos($mask, '@') !== false) {
                list($controller, $action) = explode('@', $mask, 2);
            } else {
                $controller = $mask;
                $action = null;
            }
            if (class_exists($controller)) {
                $extension = MapHelper::getExtensionFromController($controller);
                $shortName = strpos($controller, '\\') !== false
                    ? substr($controller, strrpos($controller, '\\')+1)
                    : substr($controller, strrpos($controller, '_')+1);
        
                if (is_null($action)) {
                    // grant controller
                    return array($extension, $shortName);
                } else {
                    // grant action
                    return array($extension, $shortName, $action);
                }
            } else {
                \common_Logger::w('Unknown controller '.$controller);
            }
        
            /// array masks
        } elseif (is_array($mask)) {
            if (isset($mask['act']) && isset($mask['mod']) && isset($mask['ext'])) {
                return array($mask['ext'], $mask['mod'], $mask['act']);
            } elseif (isset($mask['mod']) && isset($mask['ext'])) {
                return array($mask['ext'], $mask['mod']);
            } elseif (isset($mask['ext'])) {
                return array($mask['ext']);
            } elseif (isset($mask['controller'])) {
                $extension = MapHelper::getExtensionFromController($mask['controller']);
                $shortName = strpos($mask['controller'], '\\') !== false
                    ? substr($mask['controller'], strrpos($mask['controller'], '\\')+1)
                    : substr($mask['controller'], strrpos($mask['controller'], '_')+1)
                    ;
                return array($extension, $shortName);
            } elseif (isset($mask['act']) && strpos($mask['act'], '@') !== false) {
                list($controller, $action) = explode('@', $mask['act'], 2);
                $extension = MapHelper::getExtensionFromController($controller);
                $shortName = strpos($controller, '\\') !== false
                    ? substr($controller, strrpos($controller, '\\')+1)
                    : substr($controller, strrpos($controller, '_')+1)
                    ;
                return array($extension, $shortName, $action);
            } else {
                \common_Logger::w('Uninterpretable filter in '.__CLASS__);
            }
        } else {
            \common_Logger::w('Uninterpretable filtertype '.gettype($mask));
        }
        return array();
    }
45449
protected function _buildClassesNames($names, array $masks)
    {
        if (!is_array($names)) {
            $names = array($names);
        }
        $return_names = array();
        foreach ($names as $_name) {
            foreach ($masks as $_mask) {
                $return_names[] = sprintf($_mask, TextHelper::toCamelCase($_name));
            }
        }
        return $return_names;
    }
44547
protected function mask($payload)
    {
        $length = strlen($payload);
        $mask = $this->getMask();

        $unmasked = '';
        for ($i = 0; $i < $length; $i++) {
            $unmasked .= $payload[$i] ^ $mask[$i % 4];
        }

        return $unmasked;
    }
1209397
public static function getMSB(int $mask): int
    {
        $scan = 1;
        $msb = 0;
        while ($mask >= $scan) {
            $msb++;
            $scan <<= 1;
            if ($mask < $scan) {
                break;
            }
        }
        return $msb;
    }
1177146
public function updateLanguageMask( $mask = false )
    {
        if ( $mask === false )
        {
            $locales = array();
            foreach ( $this->getTranslations() as $translation )
            {
                $locales[] = $translation->attribute( 'locale' );
            }

            $mask = eZContentLanguage::maskByLocale( $locales, $this->isAlwaysAvailable() );
        }

        $this->setAttribute( 'language_mask', $mask );
        $this->store();
    }
251371
public function write($mask = '%s')
    {
        $str='';
        foreach ($this->cleanStack($this->get()) as $entry) {
            $str .= (strlen($str)>0 ? $this->separator : '').$entry;
        }
        $title_str = Html::writeHtmlTag('title', strip_tags($str));
        return sprintf($mask, $title_str);
    }
1113368
public static function values($mask, array $values)
    {
        foreach ($values as $k => $v) {
            $mask = str_replace('{' . $k . '}', $v, $mask);
        }

        return $mask;
    }
975628
public static INDArray reverseTimeSeriesMask(INDArray mask){
        if(mask == null){
            return null;
        }
        if(mask.rank() == 3){
            //Should normally not be used - but handle the per-output masking case
            return reverseTimeSeries(mask);
        } else if(mask.rank() != 2){
            throw new IllegalArgumentException("Invalid mask rank: must be rank 2 or 3. Got rank " + mask.rank()
                    + " with shape " + Arrays.toString(mask.shape()));
        }

        // FIXME: int cast
        int[] idxs = new int[(int) mask.size(1)];
        int j=0;
        for( int i=idxs.length-1; i>=0; i--){
            idxs[j++] = i;
        }

        return Nd4j.pullRows(mask, 0, idxs);
    }
977931
public static function applyMask($text, $mask)
    {
        $length = strlen($text);
        $buff = '';

        $special = array('/', '.', '-', '_', ' ');

        for ($i = 0, $j = 0; $i < $length; $i++, $j++) {
            if (!isset($text[$i]) || !isset($mask[$j])) {
                break;
            }

            if (in_array($mask[$j], $special)) {
                $buff .= $mask[$j];
                $j++;
            }

            $buff .= $text[$i];
        }

        return $buff;
    }
261136
def get_submask(self, *args, **kwargs) -> masktools.CustomMask:
        
        if args or kwargs:
            masks = self.availablemasks
            mask = masktools.CustomMask(numpy.full(self.shape, False))
            for arg in args:
                mask = mask + self._prepare_mask(arg, masks)
            for key, value in kwargs.items():
                mask = mask + self._prepare_mask(key, masks, **value)
            if mask not in self.mask:
                raise ValueError(
                    f'Based on the arguments `{args}` and `{kwargs}` '
                    f'the mask `{repr(mask)}` has been determined, '
                    f'which is not a submask of `{repr(self.mask)}`.')
        else:
            mask = self.mask
        return mask
566856
public function has($mask)
    {
        if (is_string($mask) && defined($name = 'static::MASK_'.strtoupper($mask))) {
            $mask = constant($name);
        } elseif (!is_int($mask)) {
            throw new InvalidArgumentException('$mask must be an integer.');
        }

        return ($this->mask & $mask) != 0;
    }
353164
public function setDefaultAttachmentMask($mask) {
        if(class_exists($mask)) {
            $this->default_attachment_mask = $mask;

            return $this;
        }

        throw new MaskNotFoundException("Unknown mask provided: ".$mask);
    }
341437
static function jsArrayByMask( $mask )
    {
        $localList = array();
        $languages = eZContentLanguage::prioritizedLanguagesByMask( $mask );
        foreach ( $languages as $key => $language )
        {
            $localList[] = array( 'locale' => $language->attribute( 'locale' ),
                                  'name'   => $language->attribute( 'name' ) );
        }

        if ( $localList )
        {
            return json_encode( $localList );
        }
        else
        {
            return false;
        }
    }
934840
public function rightTrim(string $mask = null): self
    {
        return new self(
            $mask === null ? \rtrim((string) $this) : \rtrim((string) $this, $mask),
            $this->encoding
        );
    }
866748
protected function formatOurNumber($mask = false)
    {
        $our_number = BankInterchange\Utils::padNumber(
            $this->title->our_number,
            static::OUR_NUMBER_LENGTH
        );

        return $our_number . ($mask ? '-' : '') . $this->checkDigitOurNumber();
    }
1305761
public function getMask(array $permissions)
    {
        $maskBuilder = new MaskBuilder();

        foreach ($permissions as $permission) {
            try {
                $maskBuilder->add($permission);
            } catch (InvalidArgumentException $e) {
                throw new InvalidPermissionException('Invalid permission mask: '.$permission, $permission, $e);
            }
        }

        return $maskBuilder->get();
    }