@param $operation
@param $dependency

@return bool

@throws \Eddmash\PowerOrm\Exception\KeyError
@throws \Eddmash\PowerOrm\Exception\ValueError
490799
private function checkDependency($operation, $dependency)
    {
        //['target' => $addedModelName, 'type' => true, 'action' => false]
        $target = ArrayHelper::getValue($dependency, 'target');
        $type = ArrayHelper::getValue($dependency, 'type');
        $action = ArrayHelper::getValue($dependency, 'action');
        $model = ArrayHelper::getValue($dependency, 'model', null);

        if (self::TYPE_MODEL === $type && self::ACTION_CREATED === $action) {
            // add model
            return
                $operation instanceof CreateModel &&
                strtolower($operation->name) === strtolower($target);
        } elseif (self::TYPE_FIELD === $type && self::ACTION_CREATED === $action) {
            // add field
            return

                $operation instanceof AddField &&
                strtolower($operation->name) === strtolower($target) &&
                strtolower($operation->modelName) === strtolower($model);
        //            ||(
            //                $operation instanceof CreateModel) &&
            //            strtolower($operation->name) === strtolower($target) &&
            //        any(dependency[2] == x for x, y in operation.fields)
            //                )
            //            )
        } elseif (self::TYPE_FIELD === $type && self::ACTION_DROPPED === $action) {
            // remove field
            return
                $operation instanceof RemoveField &&
                strtolower($operation->modelName) === strtolower($model) &&
                strtolower($operation->name) === strtolower($target);
        } elseif (self::TYPE_MODEL === $type && self::ACTION_DROPPED === $action) {
            //dropped model
            return
                $operation instanceof DeleteModel &&
                strtolower($operation->name) === strtolower($target);
        } elseif (self::TYPE_FIELD === $type && self::ACTION_ALTER === $action) {
            // altered field
            return
                $operation instanceof AlterField &&
                strtolower($operation->modelName) === strtolower($model) &&
                strtolower($operation->name) === strtolower($target);
        // Unknown dependency. Raise an error.
        } else {
            throw new ValueError(
                sprintf(
                    "Can't handle dependency %s %s '%s' ",
                    $action,
                    $target,
                    $type
                )
            );
        }
    }
797712
static public function isOperation($operation) {
    return ((string) $operation == Connect2PayClient::OPERATION_TYPE_SALE ||
        (string) $operation == Connect2PayClient::OPERATION_TYPE_AUTHORIZE);
  }
497160
protected function doCall($operation)
    {
        $this->client->send($operation);
        $result = $this->client->recv();
        if(false === $result)
        {
            return false;
        }
        if(null === $result->throwable)
        {
            return $result->result;
        }
        else
        {
            throw $result->throwable;
        }
    }
37289
public function has($relation, $operator = '>=', $count = 1, $boolean = 'and', Closure $callback = null)
    {
        if (strpos($relation, '.') !== false) {
            return $this->hasNested($relation, $operator, $count, $boolean, $callback);
        }

        $relation = $this->getHasRelationQuery($relation);

        $query = $relation->getRelationCountQuery($relation->getRelated()->newQuery(), $this);

        if ($callback) call_user_func($callback, $query);

        return $this->addHasWhere($query, $relation, $operator, $count, $boolean);
    }
111070
public function stream_lock($operation)
    {
        $operation = (int) $operation;

        if (($operation & \LOCK_UN) === \LOCK_UN) {
            return $this->releaseLock($operation);
        }

        // If the caller calls flock() twice, there's no reason to re-create the
        // lock handle.
        if (is_resource($this->lockHandle)) {
            return flock($this->lockHandle, $operation);
        }

        $this->lockHandle = $this->openLockHandle();

        return is_resource($this->lockHandle) && flock($this->lockHandle, $operation);
    }
785702
public function allowDelete($order)
    {
        // TODO: check if order once was confirmed (lookup in activity log)

        // check if order is confirmed
        if ($order->getStatus()->getId() >= OrderStatus::STATUS_CONFIRMED) {
            return false;
        }
        /** @var SalesDependencyClassInterface $dependency */
        foreach ($this->dependencyClasses as $dependency) {
            if (!$dependency->allowDelete($order)) {
                return false;
            }
        }

        return true;
    }
1348641
public function processTransaction(array $transactionData, string $operation): ProcessInterface
    {
        // When hitting the process endpoint, we only need the transactionId and operation key/value pairs, and
        // optionally the transactionAmount if we are capturing a portion of the total amount.
        $transactionData = array_filter($transactionData + ['operation' => $operation], function ($k) {
            return in_array($k, ['transactionId', 'operation', 'transactionAmount']);
        }, ARRAY_FILTER_USE_KEY);

        $uri = $this->getUri('process', $this->getParameters($transactionData));
        /** @var ProcessInterface $response */
        $response = $this->performRequest((string) $uri);

        Assert::isInstanceOf($response, ProcessInterface::class, 'Invalid response');

        return $response;
    }
512087
public function set($name, Dependency $dependency)
    {
        $required = isset($this->dependencies[$name]) && $this->dependencies[$name]->isRequired();
        $this->dependencies[$name] = new Requirement($dependency, $required);

        return $this;
    }
606678
public function GetOperationCount($Operation) {
      if ($Operation == 'edits')
         $Operation = array('edit', 'delete');
      else
         $Operation = explode(',', $Operation);
      
      sort($Operation);
      array_map('ucfirst', $Operation);
      $CacheKey = 'Moderation.LogCount.'.implode('.', $Operation);
      $Count = Gdn::Cache()->Get($CacheKey);
      if ($Count === Gdn_Cache::CACHEOP_FAILURE) {
         $Count = $this->GetCountWhere(array('Operation' => $Operation));
         Gdn::Cache()->Store($CacheKey, $Count, array(
            Gdn_Cache::FEATURE_EXPIRY  => 300 // 5 minutes
         ));
      }
      return $Count;
   }
46413
protected function hasHooks($operation)
    {
        return $this->enableHooks &&
            is_subclass_of($this->class, Hookable::class) &&
            (method_exists($this->class, "before$operation") || method_exists($this->class, "after$operation"));
    }
871811
protected function isOperatorAllowed(BaseOperator $operator)
    {
        if (!empty($this->children)) {
            throw new \RuntimeException('The "Not" operator can only have 1 child operator.');
        }
        if ($operator instanceof ContainsOperatorsInterface) {
            throw new LdapQueryException('Cannot add an operator to bNot that can contain other operators.');
        }
    }
1263201
public function has($relation, $operator = '>=', $count = 1, $boolean = 'and', $callback = null)
    {
        $entity = $this->mapper->newInstance();

        $relation = $this->getHasRelationQuery($relation, $entity);

        $query = $relation->getRelationCountQuery($relation->getRelatedMapper()->getQuery(), $this);

        if ($callback) {
            call_user_func($callback, $query);
        }

        return $this->addHasWhere($query, $relation, $operator, $count, $boolean);
    }
774682
public function has($relation, $operator = '>=', $count = 1, $boolean = 'and', $callback = null)
	{
		$relation = $this->getHasRelationQuery($relation);

		$query = $relation->getRelationCountQuery($relation->getRelated()->newQuery(), $this);

		if ($callback) call_user_func($callback, $query);

		return $this->addHasWhere($query, $relation, $operator, $count, $boolean);
	}
66669
public function lock($operation)
    {
        if ((LOCK_NB & $operation) == LOCK_NB) {
            $this->lock = $operation - LOCK_NB;
        } else {
            $this->lock = $operation;
        }

        return $this;
    }
276142
public function execute($operation, $parameter = array(), $version = null)
    {
        // remove '/' from operation
        $operation = preg_replace('/\//', '', $operation);

        $className = 'RakutenRws_Api_Definition_'.$operation;
        if (!class_exists($className)) {
            throw new LogicException('Operation is not definied.');
        }

        $api = new $className($this, $this->options);
        if ($version !== null) {
            $api->setVersion($version);
        }

        return $api->execute($parameter);
    }
906162
protected function executeOperation(LdapOperationInterface $operation, LogOperation $log = null)
    {
        $lastServer = $this->connection->getServer();
        try {
            $this->connectIfNotBound($operation);
            $lastServer = $this->connection->getServer();
            $handler = $this->getOperationHandler($operation);
            $handler->setOperationDefaults($operation);
            $this->logStart($log);
            $this->invalidateCacheIfNeeded($operation);
            list($result, $usedCache, $cacheKey) = $this->getCacheOrHandlerResult($operation, $handler, $log);
            $this->cacheResultIfNeeded($operation, $result, $usedCache, $cacheKey);

            return $result;
        } catch (\Throwable $e) {
            $this->logExceptionAndThrow($e, $log);
        } catch (\Exception $e) {
            $this->logExceptionAndThrow($e, $log);
        } finally {
            $this->logEnd($log);
            // It would not have set controls or switched servers if the cache was used...
            if (isset($usedCache) && $usedCache === false) {
                $this->resetLdapControls($operation);
                $this->switchServerIfNeeded($this->connection->getServer(), $lastServer, $operation);
            }
            $this->dispatcher->dispatch(new LdapOperationEvent(Event::LDAP_OPERATION_EXECUTE_AFTER, $operation, $this->connection));
        }
    }
12499
private <T> T execute(Operation<T> operation) throws Exception {
    return execute(operation, null);
  }