Return MongoDB profiler results (or disable logging)
@param $flag bool
@return string
769087
function log($flag=TRUE) {
		if ($flag) {
			$cursor=$this->db->selectcollection('system.profile')->find();
			foreach (iterator_to_array($cursor) as $frame)
				if (!preg_match('/\.system\..+$/',$frame['ns']))
					$this->log.=date('r',$this->legacy() ?
						$frame['ts']->sec : (round((string)$frame['ts'])/1000)).
						' ('.sprintf('%.1f',$frame['millis']).'ms) '.
						$frame['ns'].' ['.$frame['op'].'] '.
						(empty($frame['query'])?
							'':json_encode($frame['query'])).
						(empty($frame['command'])?
							'':json_encode($frame['command'])).
						PHP_EOL;
		} else {
			$this->log=FALSE;
			if ($this->legacy)
				$this->db->setprofilinglevel(-1);
			else
				$this->db->command(['profile'=>-1]);
		}
		return $this->log;
	}
925374
protected static function maskHasFlag($mask, $flag)
    {
        $flag   = (int)$flag;
        return ((int)$mask & $flag) === $flag;
    }
434850
public function findOne(
        $query = [],
        $fields = [],
        $timeout = 2000
    ) {
        $this->getContext()->getLog()->profileStart($this->profileName . __FUNCTION__);
        $options = [
            'socketTimeoutMS' => $timeout
        ];
        $out = $this->mongoCollection->findOne($query, $fields, $options);
        if ($out === null) {
            return [];
        }
        $this->getContext()->getLog()->profileEnd($this->profileName . __FUNCTION__);

        return $out;
    }
605345
public static function convertFromDelegateFlags($flags = null)
    {
        if (null === $flags) {
            return self::NOPARAM;
        }

        $converted = 0;

        foreach (self::$flagMap as $from => $to) {
            if ($flags & $to) {
                $converted |= $from;
            }
        }

        return $converted;
    }
347269
public function getByToken($token)
    {
        if (null === $this->profiler) {
            throw new \RuntimeException('Invalid profiler instance.');
        }

        $profile = $this->profiler->loadProfile($token);

        // In case no results were found
        if (!$profile instanceof Profile) {
            return array(array(), 0);
        }

        try {
            /** @var TranslationDataCollector $collector */
            $collector = $profile->getCollector('translation');
            $messages = $collector->getMessages();

            $transUnits = array();
            foreach ($messages as $message) {
                $transUnit = $this->storage->getTransUnitByKeyAndDomain($message['id'], $message['domain']);

                if ($transUnit instanceof TransUnit) {
                    $transUnits[] = $transUnit;
                } elseif (true === $this->createMissing) {
                    $transUnits[] = $transUnit = $this->transUnitManager->create($message['id'], $message['domain'], true);
                }

                // Also store the translation if profiler state was defined
                if (!$transUnit->hasTranslation($message['locale']) && $message['state'] === DataCollectorTranslator::MESSAGE_DEFINED) {
                    $file = $this->fileManager->getFor(sprintf('%s.%s.%s', $message['domain'], $message['locale'], $this->defaultFileFormat));

                    $this->transUnitManager->addTranslation($transUnit, $message['locale'], $message['translation'], $file, true);
                }
            }

            return array($transUnits, count($transUnits));

        } catch (\InvalidArgumentException $e) {

            // Translation collector is a 2.7 feature
            return array(array(), 0);
        }
    }
402285
public function get($key, array $flags = null)
    {
        try {
            $node = $this->getNode($key, $flags);

            return $node['value'];
        } catch (KeyNotFoundException $ex) {
            throw $ex;
        }
    }
1229610
public function getQueryProfile($queryId)
    {
        if (!array_key_exists($queryId, $this->_queryProfiles)) {
            /**
             * @see Zend_Db_Profiler_Exception
             */
            // require_once 'Zend/Db/Profiler/Exception.php';
            throw new Zend_Db_Profiler_Exception("Query handle '$queryId' not found in profiler log.");
        }

        return $this->_queryProfiles[$queryId];
    }
722499
public function arsort($flags = SORT_REGULAR)
    {
        $this->_modified = true;
        return arsort($this->_storage, $flags);
    }
1159647
public function getMatchAll(string $pattern, int $flags = PREG_PATTERN_ORDER, int $offset = 0)
	{
		return preg_match_all($pattern, $this->str, $matches, $flags, $offset) === false ? null : $matches;
	}
1281460
public function setFlag(string $flag): bool
    {
        $result = \imap_setflag_full($this->resource->getStream(), (string) $this->getNumber(), $flag, \ST_UID);

        $this->clearHeaders();

        return $result;
    }
1135607
static public function searchFile($root, $pattern = '*', $flags = 0)
    {
        $dirs = self::listDirs($root);
        array_unshift($dirs, $root);
        
        $foundFiles = [];
        
        foreach ($dirs as $dir) {
            $filePatt = $dir . '/' . $pattern;
            $files = glob($filePatt, $flags);
        
            if ($files) {
                $foundFiles = array_merge($foundFiles, $files);
            }
        }
        
        return $foundFiles;
    }
784772
public function getFlag(string $flag, $default = null) {
		if( !array_key_exists($flag, $this->flags) )
			return $default;
		return $this->flags[$flag];
	}
796949
public function get($flag)
    {
        if (!array_key_exists($flag, $this->pinputs)) {
            throw new \Exception('Input ' . $flag . ' cannot be found');
        } else {
            return $this->pinputs[$flag];
        }
    }
325553
private static function getImageFlag(array $flags): int
    {
        $res = 0;
        foreach ($flags as $flag) {
            $res |= constant(Image::class . '::' . $flag);
        }
        return $res;
    }
1259102
protected function getData($check = false)
    {
        $data = parent::getData($check);
        $data['login'] = UserHelper::getUserLogin(\common_session_SessionManager::getSession()->getUser());

        if ($this->hasRequestParameter('workstation')) {
            $data[PaginatedSqlStorage::DIAGNOSTIC_WORKSTATION] = \tao_helpers_Display::sanitizeXssHtml(trim($this->getRequestParameter('workstation')));
        }

        return $data;
    }
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;
    }
1302177
public function getOption($flag) {
        return isset($this->options[$flag]) ? $this->options[$flag] : null;
    }