Add a trait to avoid code duplicates

This commit is contained in:
Francis Hilaire 2024-02-22 18:31:05 +01:00 committed by Grzegorz Sadowski
parent 475250ca15
commit 30d3af2d13
No known key found for this signature in database
GPG key ID: EF87FF4E6E3BD364
7 changed files with 51 additions and 57 deletions

View file

@ -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;
}
}

View file

@ -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;
}
}

View file

@ -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;
}

View file

@ -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;
}
}

View file

@ -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;
}
}

View file

@ -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;
}
}

View file

@ -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;
}
}