TODO: need test
обновление времени последнего захода пользователя
@return bool
@throws Exception
336258
public function updateLastEntering(): bool
    {
        $this->last_entering_date = time();
        if (!$this->save()) {
            throw new Exception(\Yii::t('app', 'Ошибка обновления даты входа'));
        }
        return true;
    }
898615
public function verify()
    {
        $data = $_POST;
        $sign = $data['sign'];
        unset($data['sign_type']);

        if (Helper::verify($data, $sign) === false) {
            throw new \Exception('支付宝异步通知验签失败');
        }

        foreach ($data as &$value) {
            $value = mb_convert_encoding($value, 'utf-8', $data['charset'] ? $data['charset'] : 'gb2312');
        }
        return $data;
    }
741246
protected function _exception() {
        $url = '.' . $this->request->src . '.' . $this->request->controller . '.' . $this->request->action;

        if (in_array($url, $this->config['user']['security']['spam']['config']['exception'])) {
            $this->_exception = true;
        }

        return $this->_exception;
    }
751332
private function ignoreWarnings()
    {
        if (is_bool($this->configuration[self::IGNORE_WARNINGS_CONFIG_KEY]) === false) {
            throw new Exception(sprintf('Invalid «%s» config key.', self::IGNORE_WARNINGS_CONFIG_KEY));
        }

        /* @var $ignoreWarnings bool */
        $ignoreWarnings = $this->configuration[self::IGNORE_WARNINGS_CONFIG_KEY];

        return $ignoreWarnings;
    }
223574
public function execAction()
    {
        //no action defined
        if(!$this->action) {
            throw new \Exception(sprintf('no action defined for subject %s', $this->name));
        }
        //exec method
        try {
            $this->checkTraitsInjections();
            $this->traitsInit();
            $this->{'exec'.$this->sanitizeAction($this->action)}();
        } catch(Exception $exception) {
        //no method defined
            throw new Exception(sprintf('no method for handling %s %s %s', AREA, $this->name, $this->action));
        }
    }
141692
protected function createIPCSemaphore()
    {
        $this->fileIPC2 = '/tmp/'.mt_rand().md5($this->getName()).'.sem';

        touch($this->fileIPC2);

        $sem_key = ftok($this->fileIPC2, 't');
        if ($sem_key === -1) {
            throw new Exception('Fatal exception creating semaphore (ftok)');
        }

        $this->internalSemaphoreKey = shmop_open($sem_key, 'c', 0644, 10);
        if (!$this->internalSemaphoreKey) {
            return false;
        }

        return true;
    }
939529
protected function validate()
    {
        $result = $this->request($action = 'CheckCredits');
        if ((int) $result <= 0) {
            throw new Exception($this->config['codes']['-100']);
        }
        return $result;
    }
442869
public function verify()
    {
        $data = file_get_contents("php://input");
        $data = Xml::xmlToArr($data);
        if ($data['sign'] != Helper::signature($data, Datasheet::get('md5_key'))) {
            throw new \Exception('微信异步通信签名验证失败');
        }
        return $data;
    }
751472
public function check()
    {
        try {
            $this->goodPools = getInstance()->sysCache->get($this->name) ?? [];

            if (empty($this->goodPools)) {
                return false;
            }

            $newMaster = $this->goodPools['master'];
            $newSlaves = $this->goodPools['slaves'];

            if (empty($newMaster)) {
                writeln('Redis Proxy No master redis server in master-slave config!');
                throw new Exception('No master redis server in master-slave config!');
            }

            if ($this->master !== $newMaster) {
                $this->master = $newMaster;
                writeln('Redis Proxy master node change to ' . $newMaster);
            }

            if (empty($newSlaves)) {
                writeln('Redis Proxy No slave redis server in master-slave config!');
                throw new Exception('No slave redis server in master-slave config!');
            }

            $loses = array_diff($this->slaves, $newSlaves);
            if ($loses) {
                $this->slaves = $newSlaves;
                writeln('Redis Proxy slave nodes change to ( ' . implode(
                    ',',
                    $newSlaves
                ) . ' ), lost ( ' . implode(',', $loses) . ' )');
            }

            $adds = array_diff($newSlaves, $this->slaves);
            if ($adds) {
                $this->slaves = $newSlaves;
                writeln('Redis Proxy slave nodes change to ( ' . implode(
                    ',',
                    $newSlaves
                ) . ' ), add ( ' . implode(',', $adds) . ' )');
            }

            return true;
        } catch (Exception $e) {
            writeln('Redis Proxy ' . $e->getMessage());
            return false;
        }
    }
1132810
public function parse()
    {
        // Split up the TAP string into an array of lines, then
        // trim all of the lines so there's no leading or trailing whitespace.
        $this->lines = array_map('rtrim', explode("\n", $this->tapString));
        $this->lineNumber = 0;

        $this->testCount = false;
        $this->results = array();

        $header = $this->findTapLog();

        $line = $this->nextLine();
        if ($line === $header) {
            throw new Exception("Duplicated TAP log, please check the configuration.");
        }

        while ($line !== false && ($this->testCount === false || count($this->results) < $this->testCount)) {
            $this->parseLine($line);
            $line = $this->nextLine();
        }

        if (false !== $this->testCount && count($this->results) !== $this->testCount) {
            throw new Exception(Lang::get('tap_error'));
        }

        return $this->results;
    }
209726
public function fetch()
        {
            try {
                if ($this->values = $this->statement->fetch(\PDO::FETCH_ASSOC)) {
                    return $this->values;
                } else {
                    return false;
                }
            } catch (\PDOException $e) {
                throw new Exception('An error occured while trying to fetch the result: "' . $e->getMessage() . '"');
            }
        }
246633
public function save() {
		if( empty($this->modFields) || $this->isDeleted() ) {
			return false;
		}
		
		$data = array_filterbykeys($this->data, $this->modFields);
		if( !$data ) {
			throw new Exception('No updated data found but there is modified fields, unable to update');
		}
		$operation = $this->getUpdateOperation($data, $this->modFields);
		// Do not validate, new data are invalid due to the fact the new data are already in object
		// 		$operation->validate();
		$r = $operation->run();
		$this->modFields = array();
		if( !$this->onSavedInProgress ) {
			// Protect script against saving loops
			$this->onSavedInProgress = true;
			static::onSaved($data, $this);
			$this->onSavedInProgress = false;
		}
		return $r;
	}
9612
public function show()
        {
            try {

                $result = FALSE;

                if (is_null($this->pestObject))
                    throw new Exception("PEST Object not provided or is null", 503);

                $uri = "/channels";
                $result = $this->pestObject->get($uri);

                return $result;


            } catch (Pest_NotFound $e) {
                $this->phpariObject->lasterror = $e->getMessage();
                $this->phpariObject->lasttrace = $e->getTraceAsString();

                return FALSE;
            } catch (Pest_BadRequest $e) {
                $this->phpariObject->lasterror = $e->getMessage();
                $this->phpariObject->lasttrace = $e->getTraceAsString();

                return FALSE;
            } catch (Exception $e) {
                $this->phpariObject->lasterror = $e->getMessage();
                $this->phpariObject->lasttrace = $e->getTraceAsString();

                return FALSE;
            }
        }
178091
protected function checkRequired()
    {
        $errors = new Exceptions();
        foreach ($this->getRequiredKeys() as $required) {
            if (!isset($this->$required)) {
                $errors->add(new Exception('Required property "' . $required . '" is missing'));
            }
        }
        if (!$errors->empty()) {
            throw $errors;
        }
        return true;
    }
1274749
public function execute()
    {
        
        if (null === $this->statement) {
            throw new Exception('The database statement resource is not currently set.');
        }
        if ($this->statement->execute()) {
            
            if (($metaData = $this->statement->result_metadata()) !== false) {
                foreach ($metaData->fetch_fields() as $col) {
                    ${$col->name}   = null;
                    $results[]      = &${$col->name};
                    $cols[]         = $col->name;
                }
                
                call_user_func_array([$this->statement, 'bind_result'], $results);
                
                $this->stmt_results = $results;
                $this->stmt_cols = $cols;
            }
            return true;
        }
        return false;
    }
262112
public function updateDB()
    {
        if (($fileName = $this->getArchive()) === false) {
            throw new Exception('Ошибка загрузки архива.');
        }
        $zip = new \ZipArchive;
        if ($zip->open($fileName) !== true) {
            @unlink($fileName);
            throw new Exception('Ошибка распаковки.');
        }

        $this->generateIpTable($zip);
        $this->generateCityTables($zip);
        $zip->close();
        @unlink($fileName);
    }
357302
public function isValid()
    {
        $value = $this->field->getValue();

        if (is_array($value) || is_object($value)) {
            throw new \Exception("This validator only works on scalar types!");
        }

        // required but not given
        if ($this->required && $value == null) {
            return false;
        } // if the field is not required and the value is empty, then it's also valid
        elseif (!$this->required && $value == "") {
            return true;
        }

        $match = preg_match($this->regex, $value);

        return $this->not ? !$match : $match;
    }