Get Bitflags

@param array $flags

@return integer
966511
private function getBitflags(array $flags)
    {
        $val = null;
        foreach ($flags as $flag) {
            $val = $val | $flag;
        }

        return $val;
    }
1343718
public function getFlags($command = null)
    {
        $option = $command ? 'flags.'.$command : 'flags';

        return $this->getOption($option, true);
    }
922670
public function isFlagSet($flag)
    {
        if (in_array($flag, $this->flags->all()->toArray())) {
            return true;
        }
        return false;
    }
963997
public function setFlags($flags)
    {
        if ($flags !== null) {
            if (! in_array($flags, [State::SAVED, State::DELETED, State::DELETED | State::SAVED], true)) {
                $message = 'Flags were %s, but need to be State::SAVED, State::DELETED or State::DELETED | State::SAVED';
                throw new InvalidArgumentException(sprintf($message, $flags));
            }

            $this->flags = $flags;
        }

        return $this;
    }
376235
public function update_user_flags($flags) {
        global $DB;
        if ($flags->userid <= 0 || $flags->assignment <= 0 || $flags->id <= 0) {
            return false;
        }

        $result = $DB->update_record('assign_user_flags', $flags);
        return $result;
    }
560301
protected function flagsToStr($flags)
    {
        foreach ((array)$flags as $idx => $flag) {
            if ($flag = $this->flags[strtoupper($flag)]) {
                $flags[$idx] = $flag;
            }
        }

        return implode(' ', (array)$flags);
    }
681984
public function reverseTransform($flags)
    {
        if (null === $flags) {
            return null;
        }

        if (!\is_array($flags)) {
            throw new TransformationFailedException(sprintf(
                'Expected array. Got "%s".',
                \is_object($flags) ? \get_class($flags) : \gettype($flags)
            ));
        }

        if (0 === \count($flags)) {
            return FlaggedEnum::NONE;
        }

        $bitmask = 0;
        foreach ($flags as $flag) {
            if (!\is_int($flag)) {
                throw new TransformationFailedException(sprintf(
                    'Expected array of integers. Got a "%s" inside.',
                    \is_object($flag) ? \get_class($flag) : \gettype($flag)
                ));
            }
            $bitmask |= $flag;
        }

        if (!$this->isAcceptableValueForEnum($bitmask)) {
            throw new TransformationFailedException(sprintf(
                'Invalid bitmask %s for "%s" flagged enum.',
                $bitmask,
                $this->enumClass
            ));
        }

        return $bitmask;
    }
737888
public function getFlagValues()
    {
        $this->parseIfNotParsed();
        return array_map(function(Option $flag) {
            return $flag->getValue();
        }, $this->dedupeFlags());
    }
1364624
private static function decodeFlags($flags): array
    {
        return [
            'qr' => $flags >> 15 & 0x1,
            'opcode' => $flags >> 11 & 0xf,
            'aa' => $flags >> 10 & 0x1,
            'tc' => $flags >> 9 & 0x1,
            'rd' => $flags >> 8 & 0x1,
            'ra' => $flags >> 7 & 0x1,
            'z' => $flags >> 4 & 0x7,
            'rcode' => $flags & 0xf,
        ];
    }
356840
public function getDigits(array $decimals)
    {
        $digits = [];

        foreach ($decimals as $decimal) {
            $digits[] = $this->digits->getDigit($decimal);
        }

        return $digits;
    }
799452
public function removeFlag($flags)
    {
        $this->bitmask = $this->bitmask & ~$this->getMaskFromFlags($flags);

        return $this;
    }
252409
private function getResult(string $value, int $flags)
    {
        if (($flags & self::F_PACKED) !== self::F_PACKED) {
            $value = $this->removeTerminationNull($value);
        }

        $out = null;
        if (($flags & self::F_SERIALIZED) === self::F_SERIALIZED) {
            $out = Serializer::unserialize($value);
        }

        if (($flags & self::F_IS_BOOL) === self::F_IS_BOOL) {
            $out = (bool)$value;
        } else if (($flags & self::F_IS_INT) === self::F_IS_INT) {
            if (($flags & self::F_PACKED) === self::F_PACKED) {
                $res = unpack(self::P_INT . 'num', $value);
                $out = $res['num'];
                unset($res);
            } else {
                $out = (int)$value;
            }

        } else if (($flags & self::F_IS_FLOAT) === self::F_IS_FLOAT) {
            if (($flags & self::F_PACKED) === self::F_PACKED) {
                $res = unpack(self::P_FLOAT . 'num', $value);
                $out = $res['num'];
                unset($res);
            } else {
                $out = (double)$value;
            }
        } else if (($flags & self::F_IS_STRING) === self::F_IS_STRING) {
            $out = (string)$value;
        } else if (($flags & self::F_IS_NULL) === self::F_IS_NULL) {
            $out = null;
        } else if (($flags & self::F_IS_ARRAY) === self::F_IS_ARRAY) {
            if (($flags & self::F_SERIALIZED) === self::F_SERIALIZED) {
                $value = Serializer::unserialize($value);
            }

            if (($flags & self::F_IS_ARRAY_OBJECT) === self::F_IS_ARRAY_OBJECT) {
                $out = (object)$value;
            } else {
                $out = (array)$value;
            }
        }


        return $out;
    }
902551
public function extractFlags($flag)
    {
        $flags = [];

        for ($i = 0; $i <= 26; $i++) {
            if ((int) $flag & (1 << $i)) {
                array_push($flags, 1 << $i);
            }
        }

        return $flags;
    }
1122119
public function setFlags(array $flags)
    {
        // Check types of flags
        $types = array_filter($flags, 'is_array');
        if (count($types) !== count($flags)) {
            throw new InvalidArgumentException('Flags must be passed as an array');
        }

        $this->options['flags'] = $flags;
    }
875917
public function getFlagsOfType($type)
    {
        if ($this->flags === null) {
            return [];
        }

        $matches = [];

        foreach ($this->flags as $flag) {
            if ($flag->type == $type) {
                $matches []= $flag;
            }
        }

        return $matches;
    }
810234
public function getOSDS($os, $flags = 0x000000) {
    return ($this->isWrapped() || $this->isCygwin() || ($flags & self::WINDOWS_WITH_CYGWIN) || $os === self::UNIX) ? '/' : '\\';
  }
803321
public static function rGlob($pattern, $flags = 0) {
        $files = glob($pattern, $flags);
        foreach (glob(dirname($pattern).'/*', GLOB_ONLYDIR|GLOB_NOSORT) as $dir) {
            $files = array_merge($files, static::rGlob($dir.'/'.basename($pattern), $flags));
        }
        return $files;
    }