<?php declare(strict_types=1);
/*
* This file is part of PHPUnit.
*
* (c) Sebastian Bergmann <sebastian@phpunit.de>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace PHPUnit\Framework\MockObject;
use function strtolower;
use Exception;
use PHPUnit\Framework\MockObject\Builder\InvocationMocker;
use PHPUnit\Framework\MockObject\Rule\InvocationOrder;
use Throwable;
/**
* @internal This class is not covered by the backward compatibility promise for PHPUnit
*/
final class InvocationHandler
{
/**
* @var Matcher[]
*/
private $matchers = [];
/**
* @var Matcher[]
*/
private $matcherMap = [];
/**
* @var ConfigurableMethod[]
*/
private $configurableMethods;
/**
* @var bool
*/
private $returnValueGeneration;
/**
* @var Throwable
*/
private $deferredError;
public function __construct(array $configurableMethods, bool $returnValueGeneration)
{
$this->configurableMethods = $configurableMethods;
$this->returnValueGeneration = $returnValueGeneration;
}
public function hasMatchers(): bool
{
foreach ($this->matchers as $matcher) {
if ($matcher->hasMatchers()) {
return true;
}
}
return false;
}
/**
* Looks up the match builder with identification $id and returns it.
*
* @param string $id The identification of the match builder
*/
public function lookupMatcher(string $id): ?Matcher
{
if (isset($this->matcherMap[$id])) {
return $this->matcherMap[$id];
}
return null;
}
/**
* Registers a matcher with the identification $id. The matcher can later be
* looked up using lookupMatcher() to figure out if it has been invoked.
*
* @param string $id The identification of the matcher
* @param Matcher $matcher The builder which is being registered
*
* @throws MatcherAlreadyRegisteredException
*/
public function registerMatcher(string $id, Matcher $matcher): void
{
if (isset($this->matcherMap[$id])) {
throw new MatcherAlreadyRegisteredException($id);
}
$this->matcherMap[$id] = $matcher;
}
public function expects(InvocationOrder $rule): InvocationMocker
{
$matcher = new Matcher($rule);
$this->addMatcher($matcher);
return new InvocationMocker(
$this,
$matcher,
...$this->configurableMethods,
);
}
/**
* @throws Exception
* @throws RuntimeException
*/
public function invoke(Invocation $invocation)
{
$exception = null;
$hasReturnValue = false;
$returnValue = null;
foreach ($this->matchers as $match) {
try {
if ($match->matches($invocation)) {
$value = $match->invoked($invocation);
if (!$hasReturnValue) {
$returnValue = $value;
$hasReturnValue = true;
}
}
} catch (Exception $e) {
$exception = $e;
}
}
if ($exception !== null) {
throw $exception;
}
if ($hasReturnValue) {
return $returnValue;
}
if (!$this->returnValueGeneration) {
$exception = new ReturnValueNotConfiguredException($invocation);
if (strtolower($invocation->getMethodName()) === '__tostring') {
$this->deferredError = $exception;
return '';
}
throw $exception;
}
return $invocation->generateReturnValue();
}
public function matches(Invocation $invocation): bool
{
foreach ($this->matchers as $matcher) {
if (!$matcher->matches($invocation)) {
return false;
}
}
return true;
}
/**
* @throws Throwable
*/
public function verify(): void
{
foreach ($this->matchers as $matcher) {
$matcher->verify();
}
if ($this->deferredError) {
throw $this->deferredError;
}
}
private function addMatcher(Matcher $matcher): void
{
$this->matchers[] = $matcher;
}
}
At NFC Pay, your privacy is of utmost importance to us. This Privacy Policy outlines how we collect, use, share, and protect your personal information when you use our services, including our website and mobile applications.
1. Information We Collect
2. How We Use Your Information
We use the information we collect for the following purposes:
3. Sharing Your Information
We may share your personal information in the following circumstances:
4. Security of Your Information
We take the security of your personal information seriously and implement a variety of security measures, including encryption, secure servers, and access controls, to protect your data from unauthorized access, disclosure, alteration, or destruction. However, no method of transmission over the internet or electronic storage is completely secure, and we cannot guarantee its absolute security.
5. Your Privacy Rights
Depending on your location, you may have certain rights regarding your personal information, such as:
6. Third-Party Links
Our services may contain links to third-party websites or services. We are not responsible for the privacy practices or the content of these third-party sites. We encourage you to review the privacy policies of those third parties.
7. Children’s Privacy
Our services are not intended for individuals under the age of 13. We do not knowingly collect personal information from children under 13. If we become aware that we have collected personal information from a child under 13, we will take steps to delete that information.
8. Changes to This Privacy Policy
We may update this Privacy Policy from time to time to reflect changes in our practices or for other operational, legal, or regulatory reasons. We will notify you of any significant changes by posting the new Privacy Policy on our website and updating the effective date.
9. Contact Us
If you have any questions or concerns about this Privacy Policy or our data practices, please contact us at:
Email: support@nfcpay.com