final class VerificationResult in Commerce Core 8.2
Represents a tax number verification result.
Hierarchy
- class \Drupal\commerce_tax\Plugin\Commerce\TaxNumberType\VerificationResult
Expanded class hierarchy of VerificationResult
8 files declare their use of VerificationResult
- EuropeanUnionVatTest.php in modules/
tax/ tests/ src/ Kernel/ Plugin/ Commerce/ TaxNumberType/ EuropeanUnionVatTest.php - SerbianVat.php in modules/
tax/ tests/ modules/ commerce_tax_test/ src/ Plugin/ Commerce/ TaxNumberType/ SerbianVat.php - TaxNumberController.php in modules/
tax/ src/ Controller/ TaxNumberController.php - TaxNumberDefaultFormatter.php in modules/
tax/ src/ Plugin/ Field/ FieldFormatter/ TaxNumberDefaultFormatter.php - TaxNumberItem.php in modules/
tax/ src/ Plugin/ Field/ FieldType/ TaxNumberItem.php
File
- modules/
tax/ src/ Plugin/ Commerce/ TaxNumberType/ VerificationResult.php, line 8
Namespace
Drupal\commerce_tax\Plugin\Commerce\TaxNumberTypeView source
final class VerificationResult {
/**
* Available states.
*/
const STATE_SUCCESS = 'success';
const STATE_FAILURE = 'failure';
const STATE_UNKNOWN = 'unknown';
/**
* The state.
*
* One of the STATE_ constants.
*
* @var string
*/
protected $state;
/**
* The timestamp.
*
* @var int
*/
protected $timestamp;
/**
* The data.
*
* @var string
*/
protected $data;
/**
* Constructs a new VerificationResult object.
*
* @param string $state
* The state. One of the STATE_ constants.
* @param int $timestamp
* The timestamp.
* @param array $data
* The data. Optional.
*/
public function __construct(string $state, int $timestamp, array $data = []) {
$this->state = $state;
$this->timestamp = $timestamp;
$this->data = $data;
}
/**
* Constructs a success result.
*
* @param int $timestamp
* The timestamp.
* @param array $data
* The data. Optional.
*
* @return static
*/
public static function success(int $timestamp, array $data = []) : VerificationResult {
return new static(self::STATE_SUCCESS, $timestamp, $data);
}
/**
* Constructs a failure result.
*
* @param int $timestamp
* The timestamp.
* @param array $data
* The data. Optional.
*
* @return static
*/
public static function failure(int $timestamp, array $data = []) : VerificationResult {
return new static(self::STATE_FAILURE, $timestamp, $data);
}
/**
* Constructs an unkown result.
*
* @param int $timestamp
* The timestamp.
* @param array $data
* The data. Optional.
*
* @return static
*/
public static function unknown(int $timestamp, array $data = []) : VerificationResult {
return new static(self::STATE_UNKNOWN, $timestamp, $data);
}
/**
* Gets whether the verification was successful.
*
* @return bool
* TRUE if the verification was successful, FALSE otherwise.
*/
public function isSuccess() : bool {
return $this->state == self::STATE_SUCCESS;
}
/**
* Gets whether the verification failed.
*
* @return bool
* TRUE if the verification failed, FALSE otherwise.
*/
public function isFailure() : bool {
return $this->state == self::STATE_FAILURE;
}
/**
* Gets whether the verification state is unknown.
*
* Used for cases where the remote service is temporarily unavailable.
*
* @return bool
* TRUE if the verification state is unknown, FALSE otherwise.
*/
public function isUnknown() : bool {
return $this->state == self::STATE_UNKNOWN;
}
/**
* Gets the state.
*
* @return string
* The state. One of the STATE_ constants.
*/
public function getState() : string {
return $this->state;
}
/**
* Gets the timestamp.
*
* @return int
* The timestamp.
*/
public function getTimestamp() : int {
return $this->timestamp;
}
/**
* Gets the data.
*
* @return array
* The data.
*/
public function getData() : array {
return $this->data;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
VerificationResult:: |
protected | property | The data. | |
VerificationResult:: |
protected | property | The state. | |
VerificationResult:: |
protected | property | The timestamp. | |
VerificationResult:: |
public static | function | Constructs a failure result. | |
VerificationResult:: |
public | function | Gets the data. | |
VerificationResult:: |
public | function | Gets the state. | |
VerificationResult:: |
public | function | Gets the timestamp. | |
VerificationResult:: |
public | function | Gets whether the verification failed. | |
VerificationResult:: |
public | function | Gets whether the verification was successful. | |
VerificationResult:: |
public | function | Gets whether the verification state is unknown. | |
VerificationResult:: |
constant | |||
VerificationResult:: |
constant | Available states. | ||
VerificationResult:: |
constant | |||
VerificationResult:: |
public static | function | Constructs a success result. | |
VerificationResult:: |
public static | function | Constructs an unkown result. | |
VerificationResult:: |
public | function | Constructs a new VerificationResult object. |