mirror of
https://github.com/Sylius/Sylius.git
synced 2026-07-14 17:10:53 +00:00
Add a trait to avoid code duplicates
This commit is contained in:
parent
475250ca15
commit
30d3af2d13
7 changed files with 51 additions and 57 deletions
|
|
@ -14,21 +14,14 @@ declare(strict_types=1);
|
|||
namespace Sylius\Bundle\CoreBundle\PaymentRequest\Command\Offline;
|
||||
|
||||
use Sylius\Bundle\CoreBundle\PaymentRequest\Command\PaymentRequestHashAwareInterface;
|
||||
use Sylius\Bundle\CoreBundle\PaymentRequest\Command\PaymentRequestHashAwareTrait;
|
||||
|
||||
class CapturePaymentRequest implements PaymentRequestHashAwareInterface
|
||||
{
|
||||
use PaymentRequestHashAwareTrait;
|
||||
|
||||
public function __construct(
|
||||
protected string $hash,
|
||||
protected ?string $hash,
|
||||
) {
|
||||
}
|
||||
|
||||
public function getHash(): string
|
||||
{
|
||||
return $this->hash;
|
||||
}
|
||||
|
||||
public function setHash(string $hash): void
|
||||
{
|
||||
$this->hash = $hash;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,21 +14,14 @@ declare(strict_types=1);
|
|||
namespace Sylius\Bundle\CoreBundle\PaymentRequest\Command\Offline;
|
||||
|
||||
use Sylius\Bundle\CoreBundle\PaymentRequest\Command\PaymentRequestHashAwareInterface;
|
||||
use Sylius\Bundle\CoreBundle\PaymentRequest\Command\PaymentRequestHashAwareTrait;
|
||||
|
||||
class StatusPaymentRequest implements PaymentRequestHashAwareInterface
|
||||
{
|
||||
use PaymentRequestHashAwareTrait;
|
||||
|
||||
public function __construct(
|
||||
protected string $hash,
|
||||
protected ?string $hash,
|
||||
) {
|
||||
}
|
||||
|
||||
public function getHash(): string
|
||||
{
|
||||
return $this->hash;
|
||||
}
|
||||
|
||||
public function setHash(string $hash): void
|
||||
{
|
||||
$this->hash = $hash;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ namespace Sylius\Bundle\CoreBundle\PaymentRequest\Command;
|
|||
/** @experimental */
|
||||
interface PaymentRequestHashAwareInterface
|
||||
{
|
||||
public function getHash(): string;
|
||||
public function getHash(): ?string;
|
||||
|
||||
public function setHash(string $hash): void;
|
||||
public function setHash(?string $hash): void;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,29 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Sylius package.
|
||||
*
|
||||
* (c) Sylius Sp. z o.o.
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Sylius\Bundle\CoreBundle\PaymentRequest\Command;
|
||||
|
||||
trait PaymentRequestHashAwareTrait
|
||||
{
|
||||
protected ?string $hash;
|
||||
|
||||
public function getHash(): ?string
|
||||
{
|
||||
return $this->hash;
|
||||
}
|
||||
|
||||
public function setHash(?string $hash): void
|
||||
{
|
||||
$this->hash = $hash;
|
||||
}
|
||||
}
|
||||
|
|
@ -14,21 +14,14 @@ declare(strict_types=1);
|
|||
namespace Sylius\Bundle\CoreBundle\PaymentRequest\Payum\Command;
|
||||
|
||||
use Sylius\Bundle\CoreBundle\PaymentRequest\Command\PaymentRequestHashAwareInterface;
|
||||
use Sylius\Bundle\CoreBundle\PaymentRequest\Command\PaymentRequestHashAwareTrait;
|
||||
|
||||
class AuthorizePaymentRequest implements PaymentRequestHashAwareInterface
|
||||
{
|
||||
use PaymentRequestHashAwareTrait;
|
||||
|
||||
public function __construct(
|
||||
protected string $hash,
|
||||
protected ?string $hash,
|
||||
) {
|
||||
}
|
||||
|
||||
public function getHash(): string
|
||||
{
|
||||
return $this->hash;
|
||||
}
|
||||
|
||||
public function setHash(string $hash): void
|
||||
{
|
||||
$this->hash = $hash;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,21 +14,14 @@ declare(strict_types=1);
|
|||
namespace Sylius\Bundle\CoreBundle\PaymentRequest\Payum\Command;
|
||||
|
||||
use Sylius\Bundle\CoreBundle\PaymentRequest\Command\PaymentRequestHashAwareInterface;
|
||||
use Sylius\Bundle\CoreBundle\PaymentRequest\Command\PaymentRequestHashAwareTrait;
|
||||
|
||||
class CapturePaymentRequest implements PaymentRequestHashAwareInterface
|
||||
{
|
||||
use PaymentRequestHashAwareTrait;
|
||||
|
||||
public function __construct(
|
||||
protected string $hash,
|
||||
protected ?string $hash,
|
||||
) {
|
||||
}
|
||||
|
||||
public function getHash(): string
|
||||
{
|
||||
return $this->hash;
|
||||
}
|
||||
|
||||
public function setHash(string $hash): void
|
||||
{
|
||||
$this->hash = $hash;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,21 +14,14 @@ declare(strict_types=1);
|
|||
namespace Sylius\Bundle\CoreBundle\PaymentRequest\Payum\Command;
|
||||
|
||||
use Sylius\Bundle\CoreBundle\PaymentRequest\Command\PaymentRequestHashAwareInterface;
|
||||
use Sylius\Bundle\CoreBundle\PaymentRequest\Command\PaymentRequestHashAwareTrait;
|
||||
|
||||
class StatusPaymentRequest implements PaymentRequestHashAwareInterface
|
||||
{
|
||||
use PaymentRequestHashAwareTrait;
|
||||
|
||||
public function __construct(
|
||||
protected string $hash,
|
||||
protected ?string $hash,
|
||||
) {
|
||||
}
|
||||
|
||||
public function getHash(): string
|
||||
{
|
||||
return $this->hash;
|
||||
}
|
||||
|
||||
public function setHash(string $hash): void
|
||||
{
|
||||
$this->hash = $hash;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue