sentence1
stringlengths
52
3.87M
sentence2
stringlengths
1
47.2k
label
stringclasses
1 value
function paymentButton(Payment $payment, $brand = "csob", $extensions = array()) { $payId = $payment->getPayId(); if (!$payId) { throw new Exception('Given Payment object does not have a PayId. Please provide a Payment object that was returned from paymentInit() method.'); } $payload = array( "merchantI...
Performs a payment/button API call. You need a Payment object that was already processed via paymentInit() method (or was injected with a payId that you received from other source). In response, you'll receive an array with [redirect], which should be another array with [method] and [url] items. Redirect your user to...
entailment
function customRequest($methodUrl, $inputPayload, $expectedOutputFields = array(), $extensions = array(), $method = "POST", $logOutput = false, $ignoreInvalidReturnSignature = false) { if (array_key_exists('dttm', $inputPayload) and !$inputPayload['dttm']) { $inputPayload['dttm'] = $this->getDTTM(); } if (ar...
Sends an arbitrary request to bank's API with any parameters. Use this method to call various masterpass/* API methods or any methods of API versions that may come in future and are not implemented in this library yet. $inputPayload is an associative array with data in order in which they should be signed. You can le...
entailment
function customerInfo($customerId, $returnIfHasCardsOnly = true) { $customerId = $this->getCustomerId($customerId); $this->writeToLog("customer/info started for customer $customerId"); if (!$customerId) { $this->writeToLog("no customer Id give, aborting"); return null; } $payload = array( "merchan...
Performs customer/info API call. Use this method to check if customer with given ID has any saved cards. If he does, you can show some icon or change default payment method in e-shop or do some other action. This is just an auxiliary method and is not neccessary at all. @param string|array|Payment $customerId Custome...
entailment
function receiveReturningCustomer($input = null) { $returnDataNames = array( "payId", "dttm", "resultCode", "resultMessage", "paymentStatus", "?authCode", "merchantData", // "signature" ); if (!$input) { if (isset($_GET["payId"])) $input = $_GET; elseif (isset($_POST["payId"])) $in...
Processes the data that are sent together with customer when he returns back from payment gateway. Call this method on your returnUrl to extract all data from request, validate signature, decode merchant data from base64 and return it all as an array. Method automatically reads data from GET or POST. @param array|nu...
entailment
function setLog($log) { if (!$log) { $this->logFile = null; $this->logCallback = null; } elseif (is_callable($log)) { $this->logFile = null; $this->logCallback = $log; } else { Files::create($log); $this->logFile = $log; $this->logCallback = null; } return $this; }
Sets logging for bussiness-logic level messages. @param string|callback $log String filename or callback that forwards messages to your own logging system. @return Client
entailment
function setTraceLog($log) { if (!$log) { $this->traceLogFile = null; $this->traceLogCallback = null; } elseif (is_callable($log)) { $this->traceLogFile = null; $this->traceLogCallback = $log; } else { Files::create($log); $this->traceLogFile = $log; $this->traceLogCallback = null; } retu...
Sets logging for exact contents of communication @param string|callback $log String filename or callback that forwards messages to your own logging system. @return Client
entailment
function writeToLog($message) { if ($this->logFile) { $timestamp = date("Y-m-d H:i:s"); $timestamp = str_pad($timestamp, 20); if (isset($_SERVER["REMOTE_ADDR"])) { $ip = $_SERVER["REMOTE_ADDR"]; } else { $ip = "Unknown IP"; } $ip = str_pad($ip, 15); $taggedMessage = "$timestamp $ip $messa...
@ignore @param string $message
entailment
function writeToTraceLog($message) { if ($this->traceLogFile) { $timestamp = date("Y-m-d H:i:s"); $timestamp = str_pad($timestamp, 20); if (isset($_SERVER["REMOTE_ADDR"])) { $ip = $_SERVER["REMOTE_ADDR"]; } else { $ip = "Unknown IP"; } $ip = str_pad($ip, 15); $taggedMessage = "$timestamp ...
@ignore @param string $message
entailment
protected function getPayId($payment) { if (!is_string($payment) and $payment instanceof Payment) { $payment = $payment->getPayId(); if (!$payment) { throw new Exception("Given Payment object does not have payId. Please call paymentInit() first."); } } if (is_array($payment) and isset($payment["payId...
Get payId as string and validate it. @ignore @param Payment|string|array $payment String, Payment object or array as returned from paymentInit call @return string @throws Exception
entailment
protected function getCustomerId($payment) { if (!is_string($payment) and $payment instanceof Payment) { $payment = $payment->customerId; } if (is_array($payment) and isset($payment["customerId"])) { $payment = $payment["customerId"]; } if (!is_string($payment)) { throw new Exception("Given Customer ...
Get customerId as string and validate it. @ignore @param Payment|string|array $payment String, Payment object or array as returned from paymentInit call @return string @throws Exception
entailment
protected function signRequest($arrayToSign) { $stringToSign = Crypto::createSignatureBaseFromArray($arrayToSign); $keyFile = $this->config->privateKeyFile; $signature = Crypto::signString( $stringToSign, $keyFile, $this->config->privateKeyPassword ); $this->writeToTraceLog("Signing string \"$string...
Signs array payload @param array $arrayToSign @return string Base64 encoded signature @ignore
entailment
protected function sendRequest( $apiMethod, $payload, $usePostMethod = true, $responseFieldsOrder = null, $requestFieldsOrder = null, $returnUrlOnly = false, $allowInvalidReturnSignature = false, $extensions = array() ) { $url = $this->getApiMethodUrl($apiMethod); $method = $usePostMethod; $thi...
Send prepared request. @param string $apiMethod @param array $payload @param bool|string $usePostMethod True = post, false = get, string = exact method @param array $responseFieldsOrder @param array $requestFieldsOrder @param bool $returnUrlOnly @param bool $allowInvalidReturnSignature Set to true if you want to ignor...
entailment
public function asArray() { $a = array(); $a['premiseId'] = +$this->premiseId; $a['cashRegisterId'] = $this->cashRegisterId; $a['totalPrice'] = self::formatPriceValue($this->totalPrice); if ($this->delegatedVatId) { $a['delegatedVatId'] = $this->delegatedVatId; } if ($this->priceZeroVat) { $a['pr...
Export as array @return array
entailment
static function fromArray($array) { $data = new EETData(); foreach (self::$keyNames as $key) { if (array_key_exists($key, $array)) { $data->$key = $array[$key]; } } $data->rawData = $array; return $data; }
Creates EETData object from array received from API @param $array @return EETData
entailment
public function getInputData() { $a = array( 'extension' => $this->extensionId, 'dttm' => null, 'data' => $this->data->asArray(), 'verificationMode' => $this->verificationMode ? 'true' : 'false' ); return $a; }
Builds input data array @return array
entailment
public function createRequestArray(Client $client) { $sourceArray = $this->getInputData(); if (!$sourceArray) { return null; } $config = $client->getConfig(); /* if (!array_key_exists('dttm', $sourceArray)) { $sourceArray = array( 'dttm' => $this->getDTTM() ) + $sourceArray; } elseif (!...
Creates array for request. If requests for your extension are signed incorrectly because of wrong order of parts of the base string, check that order of keys in your input data given to setInputData() is the same as in extension's documentation on CSOB wiki, or extend this class and reimplement getRequestSignatureBase...
entailment
public function verifySignature($receivedData, Client $client) { $signature = isset($receivedData['signature']) ? $receivedData['signature'] : ''; if (!$signature) { return false; } $responseWithoutSignature = $receivedData; unset($responseWithoutSignature["signature"]); $baseString = $this->getRespon...
Verifies signature. @param array $receivedData @param Client $client @return bool
entailment
public function getResponseSignatureBase($responseWithoutSignature) { $keys = $this->getExpectedResponseKeysOrder(); if ($keys) { $baseString = Crypto::createSignatureBaseWithOrder($responseWithoutSignature, $keys, false); } else { $baseString = Crypto::createSignatureBaseFromArray($responseWithoutSignature...
Returns base string for verifying signature of response. If verifying signature fails because its base string has parts in incorrect order, check that the order of keys given to setExpectedResponseKeysOrder() is the same as in CSOB wiki, or reimplement this method with a better one. @param array $responseWithoutSigna...
entailment
public function getInputData() { if ($this->data) { return array( 'extension' => $this->extensionId, 'dttm' => null, 'data' => $this->data->asArray(), ); } return null; }
Builds input data array @return array
entailment
static public function fromArray($array) { $status = new EETReport(); $status->rawData = $array; if (array_key_exists('eetStatus', $array)) { $status->eetStatus = $array['eetStatus']; } if (array_key_exists('data', $array)) { $status->data = EETData::fromArray($array['data']); } if (array_key_exi...
Creates an EETStatus object from received data array @param array $array @return EETReport
entailment
public function getSignatureBase() { $fields = array(); if ($this->eetStatus !== null) { $fields[] = $this->eetStatus; } if ($this->data) { $fields[] = $this->data->getSignatureBase(); } if ($this->verificationMode !== null) { $fields[] = $this->verificationMode ? 'true' : 'false'; } if ($this...
@inheritdoc @return string
entailment
public function setResponseData($data) { $this->responseData = $data; if (isset($data['report'])) { $this->report = EETReport::fromArray($data['report']); } $this->cancels = array(); if (isset($data['cancel'])) { foreach ($data['cancel'] as $cancel) { $this->cancels[] = EETReport::fromArray($cancel)...
@inheritdoc @param array $data @return void
entailment
public function getResponseSignatureBase($dataArray) { $base = array(); $base[] = $dataArray['extension']; $base[] = $dataArray['dttm']; if ($this->report) { $base[] = $this->report->getSignatureBase(); } if ($this->cancels) { foreach ($this->cancels as $cancel) { $base[] = $cancel->getSignatureB...
@inheritdoc @param array $dataArray @return string
entailment
function addCartItem($name, $quantity, $totalAmount, $description = "") { if (count($this->cart) >= 2) { throw new Exception("This version of banks's API supports only up to 2 cart items in single payment, you can't add any more items."); } if (!is_numeric($quantity) or $quantity < 1) { throw new Exceptio...
Add one cart item. You are required to add one or two cart items (at least on API v1). Remember that $totalAmount must be given in **hundredth of currency units** (cents for USD or EUR, "halíře" for CZK) @param string $name Name that customer will see (will be automatically trimmed to 20 characters) @param number $q...
entailment
public function setMerchantData($data, $alreadyEncoded = false) { if (!$alreadyEncoded) { $data = base64_encode($data); } if (strlen($data) > 255) { throw new Exception("Merchant data can not be longer than 255 characters after base64 encoding."); } $this->merchantData = $data; return $this; }
Set some arbitrary data you will receive back when customer returns @param string $data @param bool $alreadyEncoded True if given $data is already encoded to Base64 @return Payment Fluent interface @throws Exception When the data is too long and can't be encoded.
entailment
function setRecurrentPayment($recurrent = true) { $this->payOperation = $recurrent ? self::OPERATION_RECURRENT : self::OPERATION_PAYMENT; trigger_error('setRecurrentPayment() is deprecated, use setOneClickPayment() instead.', E_USER_DEPRECATED); return $this; }
Mark this payment as a template for recurrent payments. Basically, this is a lazy method for setting $payOperation to OPERATION_RECURRENT. @param bool $recurrent @deprecated Deprecated and replaced by setOneClickPayment @return \OndraKoupil\Csob\Payment
entailment
function setOneClickPayment($oneClick = true) { $this->payOperation = $oneClick ? self::OPERATION_ONE_CLICK : self::OPERATION_PAYMENT; return $this; }
Mark this payment as one-click payment template Basically, this is a lazy method for setting $payOperation to OPERATION_ONE_CLICK @param bool $oneClick @return $this
entailment
function checkAndPrepare(Config $config) { $this->merchantId = $config->merchantId; $this->dttm = date(Client::DATE_FORMAT); if (!$this->payOperation) { $this->payOperation = self::OPERATION_PAYMENT; } if (!$this->payMethod) { $this->payMethod = "card"; } if (!$this->currency) { $this->curren...
Validate and initialise properties. This method is called automatically in proper time, you never have to call it on your own. @param Config $config @throws Exception @return Payment Fluent interface @ignore
entailment
function signAndExport(Client $client) { $arr = array(); $config = $client->getConfig(); foreach($this->fieldsInOrder as $f) { $val = $this->$f; if ($val === null) { $val = ""; } $arr[$f] = $val; } foreach ($this->auxFieldsInOrder as $f) { $val = $this->$f; if ($val !== null) { $a...
Add signature and export to array. This method is called automatically and you don't need to call is on your own. @param Client $client @return array @ignore
entailment
function getSignatureString() { $parts = array(); foreach($this->fieldsInOrder as $f) { $val = $this->$f; if ($val === null) { $val = ""; } elseif (is_bool($val)) { if ($val) { $val = "true"; } else { $val = "false"; } } elseif (is_array($val)) { // There are never more...
Convert to string that serves as base for signing. @return string @ignore
entailment
static function signString($string, $privateKeyFile, $privateKeyPassword = "") { if (!function_exists("openssl_get_privatekey")) { throw new CryptoException("OpenSSL extension in PHP is required. Please install or enable it."); } if (!file_exists($privateKeyFile) or !is_readable($privateKeyFile)) { throw ...
Signs a string @param string $string @param string $privateKeyFile Path to file with your private key (the .key file from https://iplatebnibrana.csob.cz/keygen/ ) @param string $privateKeyPassword Password to the key, if it was generated with one. Leave empty if you created the key at https://iplatebnibrana.csob.cz/ke...
entailment
static function verifySignature($textToVerify, $signatureInBase64, $publicKeyFile) { if (!function_exists("openssl_get_privatekey")) { throw new CryptoException("OpenSSL extension in PHP is required. Please install or enable it."); } if (!file_exists($publicKeyFile) or !is_readable($publicKeyFile)) { thro...
Verifies signature of a string @param string $textToVerify The text that was signed @param string $signatureInBase64 The signature encoded with Base64 @param string $publicKeyFile Path to file where bank's public key is saved (you can obtain it from bank's app https://iposman.iplatebnibrana.csob.cz/posmerchant or from...
entailment
static function createSignatureBaseFromArray($array, $returnAsArray = false) { $linearizedArray = self::createSignatureBaseRecursion($array); if ($returnAsArray) { return $linearizedArray; } return implode('|', $linearizedArray); }
Vytvoří z array (i víceúrovňového) string pro výpočet podpisu. @param array $array @param bool $returnAsArray @return string|array
entailment
static function createSignatureBaseWithOrder($data, $order, $returnAsArray = false) { $result = array(); foreach ($order as $key) { $optional = false; if ($key[0] == '?') { $optional = true; $key = substr($key, 1); } $keyPath = explode('.', $key); $pos = $data; $found = true; foreach...
Generická implementace linearizace pole s dopředu zadaným požadovaným pořadím. V $order by mělo být požadované pořadí položek formou stringových "keypath". Keypath je název klíče v poli $data, pokud je víceúrovňové, klíče jsou spojeny tečkou. Pokud keypath začíná znakem otazník, považuje se za nepovinnou a není-li ta...
entailment
protected function registerClientScript() { $js = []; $view = $this->getView(); TinyMceAsset::register($view); if ($tinyAssetBundle = TinyMceAsset::register($view)) { $xCopy = new xCopy(); $assetPath = $tinyAssetBundle->basePath; // Languag...
Registers tinyMCE js plugin @throws \yii\base\InvalidConfigException
entailment
public function buscar(Request $request, AtendimentoService $atendimentoService) { $envelope = new Envelope(); $usuario = $this->getUser(); $unidade = $usuario->getLotacao()->getUnidade(); $numero = $request->get('numero'); $atendimentos = $atendimentoService->busca...
Busca os atendimentos a partir do número da senha. @param Request $request @Route("/buscar", name="novosga_monitor_buscar", methods={"GET"})
entailment
public function transferir( Request $request, AtendimentoService $atendimentoService, ServicoService $servicoService, Atendimento $atendimento, TranslatorInterface $translator ) { $envelope = new Envelope(); $usuario = $this->getUser(); $unida...
Transfere o atendimento para outro serviço e prioridade. @param Request $request @Route("/transferir/{id}", name="novosga_monitor_transferir", methods={"POST"})
entailment
public function reativar( Request $request, Atendimento $atendimento, AtendimentoService $atendimentoService, TranslatorInterface $translator ) { $envelope = new Envelope(); $usuario = $this->getUser(); $unidade = $usuario->getLotacao()->getUnidade(); ...
Reativa o atendimento para o mesmo serviço e mesma prioridade. Só pode reativar atendimentos que foram: Cancelados ou Não Compareceu. @param Request $request @Route("/reativar/{id}", name="novosga_monitor_reativar", methods={"POST"})
entailment
public function cancelar( Request $request, AtendimentoService $atendimentoService, Atendimento $atendimento, TranslatorInterface $translator ) { $envelope = new Envelope(); $usuario = $this->getUser(); $unidade = $usuario->getLotacao()->getUnidade();...
Atualiza o status da senha para cancelado. @param Request $request @Route("/cancelar/{id}", name="novosga_monitor_cancelar", methods={"POST"})
entailment
private function getManagerOptions() { if (!$this->language) { $this->language = $this->tinyMceSettings['language']; } $managerOptions = [ 'callback' => $this->getId(), ]; if (!empty($this->filter)) { $managerOptions['filter'] ...
Manager Options @return array
entailment
public function load($path) { $key = sha1($path); $value = $this->cache->get($key); if ($value !== null) { return $value; } $this->cache->set($key, $value = $this->loader->load($path)); return $value; }
{@inheritdoc}
entailment
public function load($path) { try { return $this->firstLoader->load($path); } catch (SchemaLoadingException $e) { return $this->secondLoader->load($path); } }
{@inheritdoc}
entailment
public function load($path) { $uri = 'file://' . $path; if (!file_exists($uri)) { throw SchemaLoadingException::notFound($uri); } return $this->jsonDecoder->decode(file_get_contents($uri)); }
{@inheritdoc}
entailment
public function decode($schema) { try { return Yaml::parse($schema, Yaml::PARSE_OBJECT_FOR_MAP | Yaml::PARSE_EXCEPTION_ON_INVALID_TYPE); } catch (ParseException $e) { throw new DecodingException(sprintf('Invalid Yaml: %s', $e->getMessage()), $e->getCode(), $e); } ...
{@inheritdoc}
entailment
protected function getResponseData($path, $default = null) { $array = $this->response; if (!empty($path)) { $keys = explode('.', $path); foreach ($keys as $key) { if (isset($array[$key])) { $array = $array[$key]; } else { ...
Attempts to pull value from array using dot notation. @param string $path @param string $default @return mixed
entailment
public function get($pointer) { $value = $this->traverse($pointer); if ($value instanceof NonExistentValue) { throw InvalidPointerException::nonexistentValue($value->getValue(), $value->getPointer()); } return $value; }
@param string $pointer @return mixed @throws InvalidPointerException
entailment
public function set($pointer, $data) { if ($pointer === '') { throw new \InvalidArgumentException('Cannot replace the object with set.'); } $pointer = $this->parse($pointer); $replace = array_pop($pointer); $target = &$this->getTarget($pointer); if (is_...
@param string $pointer @param mixed $data @return void @throws InvalidPointerException @throws \InvalidArgumentException
entailment
public function remove($pointer) { if ($pointer === '') { throw new \InvalidArgumentException('Cannot remove the object.'); } $pointer = $this->parse($pointer); $remove = array_pop($pointer); $target = &$this->getTarget($pointer); if (is_array($target)...
@param string $pointer @return void
entailment
private function &getTarget(array $pointer) { $target = &$this->json; foreach ($pointer as $segment) { if (is_array($target)) { $target =& $target[$segment]; } else { $target =& $target->$segment; } } return $targe...
@param array $pointer @return mixed
entailment
private function traverse($pointer) { $parsedPointer = $this->parse($pointer); $json = $this->json; foreach ($parsedPointer as $segment) { if ($json instanceof Reference) { if (!$json->has($segment)) { return new NonExistentValue($segment, ...
Returns the value referenced by the pointer or a NonExistentValue if the value does not exist. @param string $pointer The pointer @return mixed
entailment
private function parse($pointer) { if (!is_string($pointer)) { throw InvalidPointerException::invalidType(gettype($pointer)); } if (!isset($pointer[0])) { return []; } // If the pointer is a url fragment, it needs to be url decoded. if ($poin...
Parses a JSON Pointer as defined in the specification. @see https://tools.ietf.org/html/rfc6901#section-4 @param string $pointer @return array @throws InvalidPointerException
entailment
public function dereference($schema, $uri = '') { return $this->crawl($schema, $uri, function ($schema, $pointer, $ref, $scope) { $resolved = new Reference($ref, $scope, is_internal_ref($ref) ? $schema : null); return merge_ref($schema, $resolved, $pointer); }); }
{@inheritdoc}
entailment
private function prepareArguments($schema, $uri) { if (is_string($schema)) { $uri = $schema; $schema = resolve_fragment($uri, $this->loadExternalRef($uri)); $uri = strip_fragment($uri); } return [$schema, $uri]; }
@param object|string $schema @param string $uri @return array
entailment
private function crawl($schema, $uri, callable $resolver) { list($schema, $uri) = $this->prepareArguments($schema, $uri); foreach (schema_extract($schema, 'League\JsonReference\is_ref') as $pointer => $ref) { $scope = $this->scopeResolver->resolve($schema, $pointer, $uri); ...
@param string|object $schema @param string $uri @param callable $resolver @return object
entailment
private function loadExternalRef($reference) { list($prefix, $path) = parse_external_ref($reference); return $this->loaderManager->getLoader($prefix)->load($path); }
Load an external ref and return the JSON object. @param string $reference @return object
entailment
public function dereference($schema, $uri = '') { $key = self::key($schema, $uri); return $this->remember($key, function () use ($schema, $uri) { return $this->dereferencer->dereference($schema, $uri); }); }
{@inheritdoc}
entailment
private function remember($key, Closure $callback) { $value = $this->cache->get($key); if ($value !== null) { return $value; } $this->cache->set($key, $value = $callback()); return $value; }
@param string $key @param Closure $callback @return object
entailment
private static function key($schema, $uri) { if ($uri !== '') { return sha1($uri); } return sha1(is_string($schema) ? $schema : json_encode($schema)); }
@param string|object $schema @param string $uri @return string
entailment
public function getType($class) { foreach ($this->handlers as list($service_id, $handler_class)) { if ($handler_class !== $class) { continue; } $handler = $this->container->get($service_id); if ($handler instanceof FormHandlerInterface) { ...
{@inheritdoc}
entailment
public function load($path) { if (!array_key_exists($path, $this->schemas)) { throw SchemaLoadingException::notFound($path); } $schema = $this->schemas[$path]; if (is_string($schema)) { return $this->jsonDecoder->decode($schema); } elseif (is_object(...
{@inheritdoc}
entailment
public function decode($schema) { $data = json_decode($schema, $this->assoc, $this->depth, $this->options); if (json_last_error() !== JSON_ERROR_NONE) { throw new DecodingException(sprintf('Invalid JSON: %s', json_last_error_msg())); } return $data; }
{@inheritdoc}
entailment
public function load($path) { $uri = $this->prefix . $path; $ch = curl_init($uri); curl_setopt_array($ch, $this->curlOptions); list($response, $statusCode) = $this->getResponseBodyAndStatusCode($ch); curl_close($ch); if ($statusCode >= 400 || !$response) { ...
{@inheritdoc}
entailment
private function getResponseBodyAndStatusCode($ch) { $response = curl_exec($ch); $statusCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); return [$response, $statusCode]; }
@param resource $ch @return array
entailment
public function resolve($schema, $currentPointer, $currentScope) { $current = $schema; foreach (explode('/', $currentPointer) as $segment) { if (isset($current->$segment)) { $current = $current->$segment; } $id = isset($current->{$this->keyword}) ?...
{@inheritdoc}
entailment
public function getLoader($prefix) { if (!$this->hasLoader($prefix)) { throw new \InvalidArgumentException(sprintf('A loader is not registered for the prefix "%s"', $prefix)); } return $this->loaders[$prefix]; }
Get the loader for the given prefix. @param string $prefix @return LoaderInterface @throws \InvalidArgumentException
entailment
private function registerDefaultWebLoaders() { if (function_exists('curl_init')) { $this->loaders['https'] = new CurlWebLoader('https://'); $this->loaders['http'] = new CurlWebLoader('http://'); } else { $this->loaders['https'] = new FileGetContentsWebLoader('htt...
Register the default web loaders. If the curl extension is loaded, the CurlWebLoader will be used. Otherwise the FileGetContentsWebLoader will be used. You can override this by registering your own loader for the 'http' and 'https' protocols.
entailment
public function apply(Request $request, ParamConverter $configuration) { $options = $configuration->getOptions(); $service_id = isset($options['service_id']) ? $options['service_id'] : $this->getServiceIdForClassName($configuration); $handler = $this->container-...
{@inheritdoc}
entailment
public function resolve() { if (isset($this->resolved)) { return $this->resolved; } $pointer = new Pointer($this->schema); if (is_internal_ref($this->ref) && $pointer->has($this->ref)) { return $this->resolved = $pointer->get($this->ref); } r...
Resolve the reference and return the data. @return mixed
entailment
public function get($property) { if (!$this->has($property)) { throw new \InvalidArgumentException(sprintf('Unknown property "%s"', $property)); } $schema = $this->resolve(); return pointer($schema)->get($property); }
@param string $property @return mixed @throws \InvalidArgumentException
entailment
public function getIterator() { // Recursively resolve until we hit a real schema //because you can't use get_object_vars on a reference. $schema = $this->resolve(); while ($schema instanceof Reference) { $schema = $schema->resolve(); } if (!is_object($sc...
Retrieve an external iterator @link http://php.net/manual/en/iteratoraggregate.getiterator.php @return \Traversable An instance of an object implementing <b>Iterator</b> or <b>Traversable</b> @since 5.0.0
entailment
protected function createAccessToken(array $response, AbstractGrant $grant) { return new \Stevenmaguire\OAuth2\Client\Token\AccessToken($response); }
Creates an access token from a response. The grant that was used to fetch the response can be used to provide additional context. @param array $response @param AbstractGrant $grant @return AccessToken
entailment
public function setDomain($domain) { try { $this->domain = (string) $domain; } catch (Exception $e) { throw new InvalidArgumentException( 'Value provided as domain is not a string' ); } return $this; }
Updates the provider domain with a given value. @throws InvalidArgumentException @param string $domain @return Salesforce
entailment
public function load($path) { $uri = $this->prefix . $path; set_error_handler(function () use ($uri) { throw SchemaLoadingException::create($uri); }); $response = file_get_contents($uri); restore_error_handler(); if (!$response) { throw Schema...
{@inheritdoc}
entailment
public function process() { if (Yii::$app->db->getTableSchema($this->table) == null) { throw new \yii\base\InvalidConfigException('"' . $this->table . '" not found in database. Make sure the db migration is properly done and the table is created.'); } $success = true; $items = Queue::find()->where(['and...
Sends out the messages in email queue and update the database. @return boolean true if all messages are successfully sent out
entailment
public function queue($time_to_send = 'now') { if($time_to_send == 'now') { $time_to_send = time(); } $item = new Queue(); $item->subject = $this->getSubject(); $item->attempts = 0; $item->swift_message = base64_encode(serialize($this)); $item->t...
Enqueue the message storing it in database. @param timestamp $time_to_send @return boolean true on success, false otherwise
entailment
public static function invalidButtonPosition($message = null) { $defaultMessage = sprintf('Tried giving the button to a player that is not sat down.'); $message = null === $message ? $defaultMessage : $message; return new static($message); }
@param null $message @return static
entailment
public static function notRegistered(Client $player, Table $table, $message = null) { $defaultMessage = sprintf('%s is not registered to table: "%s"', $player, $table->id()->toString()); $message = is_null($message) ? $defaultMessage : $message; return new static($message); }
@param Client $player @param Table $table @param string $message @return static
entailment
public function remove(ChipPot $removeChipPot) { return $this->reject(function (ChipPot $chipPot) use ($removeChipPot) { return $chipPot->equals($removeChipPot); })->values(); }
@var ChipPot @return ChipPotCollection
entailment
public static function invalidArgument($message = null) { $defaultMessage = sprintf('Invalid argument passed in GameParameters.'); $message = null === $message ? $defaultMessage : $message; return new static($message); }
@param null $message @return static
entailment
public static function setUp(UuidInterface $id, string $name, GameParameters $rules) { return new self($id, $name, $rules); }
@param UuidInterface $id @param string $name @param GameParameters $rules @return CashGame
entailment
public function createService(ServiceLocatorInterface $serviceLocator) { $moduleConfig = $serviceLocator->get('config')['dompdf_module']; $options = [ 'temp_dir' => $moduleConfig['temporary_directory'], 'font_dir' => $moduleConfig['font_di...
Creates an instance of Dompdf. @param ServiceLocatorInterface $serviceLocator @return Dompdf
entailment
public function hasAction(int $actionValue): bool { $count = $this ->filter(function (Action $action) use ($actionValue) { return $action->action() === $actionValue; }) ->count(); return $count > 0 ? true : false; }
@param int $actionValue @return bool
entailment
public function render($nameOrModel, $values = null) { if (!($nameOrModel instanceof PdfModel)) { throw new InvalidArgumentException(sprintf( '%s expects a PdfModel as the first argument; received "%s"', __METHOD__, (is_object($nameOrModel) ? get_c...
{@inheritdoc}
entailment
public static function createRoyalFlush(CardCollection $cards, Hand $hand): self { return new static( self::ROYAL_FLUSH, [0], $cards, 'Royal Flush', $hand ); }
@param CardCollection $cards @return SevenCardResult
entailment
public static function createStraightFlush(CardCollection $cards, Hand $hand): self { $highCard = $cards->sortByValue()->take(-1); $definition = sprintf('Straight Flush to %s', $highCard->first()->name()); return new static( self::STRAIGHT_FLUSH, [$highCard->first()-...
@param CardCollection $cards @return SevenCardResult
entailment
public static function createFourOfAKind(CardCollection $cards, Hand $hand): self { $cardGroups = $cards->groupByValue(); $firstGroup = $cardGroups->first()->first(); $kickerGroup = $cardGroups->last()->first(); $definition = sprintf('4 of a Kind - %ss', $firstGroup->name()); ...
@param CardCollection $cards @return SevenCardResult
entailment
public static function createFullHouse(CardCollection $cards, Hand $hand): self { $cardGroups = $cards->groupByValue()->take(2); $firstCardGroup = $cardGroups->first()->first(); $lastCardGroup = $cardGroups->last()->first(); $definition = sprintf( 'Full House - %ss over ...
@param CardCollection $cards @return SevenCardResult
entailment
public static function createFlush(CardCollection $cards, Hand $hand): self { $highCard = $cards->sortByValue()->take(-1); $definition = sprintf('Flush to %s', $highCard->first()->name()); return new static( self::FLUSH, [$highCard->first()->value()], $ca...
@param CardCollection $cards @return SevenCardResult
entailment
public static function createStraight(CardCollection $cards, Hand $hand): self { $highCard = $cards->sortByValue()->take(-1); $definition = sprintf('Straight to %s', $highCard->first()->name()); return new static( self::STRAIGHT, [$highCard->first()->value()], ...
@param CardCollection $cards @return SevenCardResult
entailment
public static function createThreeOfAKind(CardCollection $cards, Hand $hand): self { $cardGroups = $cards->groupByValue(); $firstCard = $cardGroups->get(0)->first(); $kicker = $cardGroups->get(1)->first(); $definition = sprintf('3 of a Kind - %ss', $firstCard->name()); retu...
@param CardCollection $cards @return SevenCardResult
entailment
public static function createTwoPair(CardCollection $cards, Hand $hand): self { $cardGroups = $cards->groupByValue(); $firstCard = $cardGroups->get(0)->first(); $secondCard = $cardGroups->get(1)->first(); $kickerCard = $cardGroups->get(2)->first(); $definition = sprintf( ...
@param CardCollection $cards @return SevenCardResult
entailment
public static function createOnePair(CardCollection $cards, Hand $hand): self { $cardGroups = $cards->groupByValue(); $pair = $cardGroups->get(0)->first(); $kicker = $cardGroups->get(1)->first(); $definition = sprintf('Pair of %ss', $pair->name()); return new static( ...
@param CardCollection $cards @return SevenCardResult
entailment
public static function createHighCard(CardCollection $cards, Hand $hand): self { $cardValues = $cards->sortByValue()->values(); $highCard = $cardValues->get(4); $definition = sprintf('High Card - %s', $highCard->name()); return new static( self::HIGH_CARD, ...
@param CardCollection $cards @return SevenCardResult
entailment
public function addChips(Chips $chips, Player $player): ChipPot { $existingChips = $this->chips()->get($player->name()) ?? Chips::zero(); $this->chips->put($player->name(), Chips::fromAmount($existingChips->amount() + $chips->amount())); if ($this->players()->findByName($player->name()) ==...
@param Chips $chips @param Player $player @return ChipPot
entailment
public function equals(ChipPot $object): bool { return static::class === get_class($object) && $this->chips() === $object->chips() && $this->players() === $object->players() && $this->total() === $object->total(); }
@param ChipPot $object @return bool
entailment
public static function playerHasNoHand(Player $player, $message = null) { $defaultMessage = sprintf('%s has not been dealt into this round', $player); $message = null === $message ? $defaultMessage : $message; return new static($message); }
@param Player $player @param null|string $message @return static
entailment
public static function notEnoughChipsInChipStack(Player $player, Chips $chips, $message = null) { $defaultMessage = sprintf('%s does not have enough chips to bet %d', $player, $chips->amount()); $message = null === $message ? $defaultMessage : $message; return new static($message); }
@param Player $player @param Chips $chips @param null|string $message @return static
entailment
public static function playerStillNeedsToAct(Player $player, $message = null) { $defaultMessage = sprintf('%s still needs to act.', $player); $message = null === $message ? $defaultMessage : $message; return new static($message); }
@param Player $player @param null|string $message @return static
entailment
public static function flopHasBeenDealt($message = null) { $defaultMessage = 'The Flop has already been dealt!'; $message = null === $message ? $defaultMessage : $message; return new static($message); }
@param null|string $message @return static
entailment
public static function turnHasBeenDealt($message = null) { $defaultMessage = 'The Turn has already been dealt!'; $message = null === $message ? $defaultMessage : $message; return new static($message); }
@param null|string $message @return static
entailment