Get image flag.

@param array $flags
@return int
325553
private static function getImageFlag(array $flags): int
    {
        $res = 0;
        foreach ($flags as $flag) {
            $res |= constant(Image::class . '::' . $flag);
        }
        return $res;
    }
865333
public static function flags2bitarray($flags, $len = 4)
    {
        $ret = 0;
        foreach ($flags as $v) {
            $ret |= $v;
        }
        return static::i2b($len, $ret);
    }
728813
public function setFlag(array $mailsIds, $flag) {
		return imap_setflag_full($this->getImapStream(), implode(',', $mailsIds), $flag, ST_UID);
	}
1340949
private static function userFlagExistsOne(array $flags, int $flag_id, int $action_id, $module_id = null) : int {
		$result = $flags[$flag_id][$action_id][$module_id] ?? null;
		if ($result === 0) {
			return 1;
		} else if ($result === 1) {
			return 2;
		}
		return 0;
	}
1117311
public function unsetFlag($flag) {
        $this->client->openFolder($this->folder_path);

        $flag = "\\".trim(is_array($flag) ? implode(" \\", $flag) : $flag);
        $status = imap_clearflag_full($this->client->getConnection(), $this->getUid(), $flag, SE_UID);
        $this->parseFlags();

        return $status;
    }
1014889
public function countMessages($flags = null)
    {
        if ($flags === null) {
            return count($this->_files);
        }

        $count = 0;
        if (!is_array($flags)) {
            foreach ($this->_files as $file) {
                if (isset($file['flaglookup'][$flags])) {
                    ++$count;
                }
            }
            return $count;
        }

        $flags = array_flip($flags);
           foreach ($this->_files as $file) {
               foreach ($flags as $flag => $v) {
                   if (!isset($file['flaglookup'][$flag])) {
                       continue 2;
                   }
               }
               ++$count;
           }
           return $count;
    }
424423
private function parseFlag($flag)
    {
        if (!isset($this->flags)) {
            $this->flags = 0;
        }

        if (is_string($flag) && defined("static::${flag}")) {
            $flag = constant("static::${flag}");
        }

        if (!is_int($flag)) {
            return 0;
        }

        return $flag;
    }
918765
public function hasFlag($flags)
    {
        $mask = $this->getMaskFromFlags($flags);

        return ($this->bitmask & $mask) === $mask;
    }
411188
public function str($flags = 0)
    {
        $ret = false;

        if ($this->match(TextTokenizer::STRING, $matches, $flags)) {
            $delimiter = $matches[2];
            $str = $matches[3];
            $str = str_replace("\\$delimiter", "$delimiter", $str);
            $ret = array($str);
        }

        return $ret;
    }
1064635
public function addFlag($flag)
    {
        if (!in_array($flag, $this->flags, true)) {
            $this->flags[] = $flag;
        }

        return $this;
    }
34364
public function flag()
    {
        $args = func_get_args();
        $num = count($args);

        if ($num > 1) {
            $this->flags[$args[0]] = $args[1];

            return $this;
        }

        if (array_key_exists($args[0], $this->flags)) {
            return $this->flags[$args[0]];
        }
    }
47058
private function _getImageToSize(array $images, int $size)
	{
		$selectedImage = null;
		$selectedSize = 0;

		foreach ($images as $image)
		{
			if (is_array($image))
			{
				$imageWidth = isset($image['width']) && is_numeric($image['width']) ? $image['width'] : 0;
				$imageHeight = isset($image['height']) && is_numeric($image['height']) ? $image['height'] : 0;
				$imageSize = max($imageWidth, $imageHeight);

				if (!$selectedImage ||
					($selectedSize < $size && $imageSize > $selectedSize) ||
					($selectedSize > $imageSize && $imageSize > $size))
				{
					$selectedImage = $image;
					$selectedSize = $imageSize;
				}
			}
		}

		return $selectedImage;
	}
1145460
protected function getFlagConfiguration($key = null)
    {
        if (null !== $key) {
            $result = (isset($this->flagConfiguration[$key])) ? $this->flagConfiguration[$key] : null;

        } else {
            $result = $this->flagConfiguration;
        }

        return $result;
    }
496050
public function ksort($flags = SORT_REGULAR)
    {
        $this->_modified = true;
        return ksort($this->_storage, $flags);
    }
627563
protected function getFlags(): ?int
	{
		if($this->version === null)
		{
			return null;
		}

		switch($this->version)
		{
			case 'v4':
				return FILTER_FLAG_IPV4;
			case 'v6':
				return FILTER_FLAG_IPV6;
			default:
				throw new RuntimeException(vsprintf('Invalid IP version [ %s ]. The accepted versions are v4 and v6.', [$this->version]));
		}
	}
221983
public function getStat(string $path, int $flags)
    {
        $entity = $this->getEntity($path);

        if (null === $entity) {
            $path = null;
        } elseif ($entity instanceof DeletedInterface) {
            $path = null;
        } elseif (!$entity->file_exists()) {
            $path = null;
        } else {
            $path = $entity->path();
        }

        if (null === $path) {
            $stat = false;
        } elseif ($flags & STREAM_URL_STAT_QUIET) {
            $stat = @stat($path);
        } else {
            $stat = stat($path);
        }

        return $stat;
    }
288471
public function get($key, $flags = 0)
    {
        if (!isset($this->config[$key])) {
            return null;
        }
        switch ($key) {
            case 'env-file':
                $val = rtrim($this->process($this->config[$key], $flags), '/\\');
                return ($flags & self::RELATIVE_PATHS == 1) ? $val : $this->realpath($val);
            default:
                return $this->process($this->config[$key], $flags);
        }
    }