-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
42 changed files
with
2,063 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,6 @@ | |
/vendor/ | ||
/tests/report | ||
/tests/mock/db_test.sqlite | ||
composer.lock | ||
.phpunit.result.cache | ||
coverage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
src/Kernel/Factories/Configurations/GooglePayConfigFactory.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
|
||
namespace Pagarme\Core\Kernel\Factories\Configurations; | ||
|
||
use Pagarme\Core\Kernel\Interfaces\FactoryCreateFromDbDataInterface; | ||
use Pagarme\Core\Kernel\ValueObjects\Configuration\GooglePayConfig; | ||
|
||
class GooglePayConfigFactory implements FactoryCreateFromDbDataInterface | ||
{ | ||
/** | ||
* @param object $data | ||
* @return GooglePayConfig | ||
*/ | ||
public function createFromDbData($data) | ||
{ | ||
$googlePayConfig = new GooglePayConfig(); | ||
|
||
if (isset($data->enabled)) { | ||
$googlePayConfig->setEnabled((bool) $data->enabled); | ||
} | ||
|
||
if (!empty($data->title)) { | ||
$googlePayConfig->setTitle($data->title); | ||
} | ||
|
||
if (!empty($data->merchantId)) { | ||
$googlePayConfig->setMerchantId($data->merchantId); | ||
} | ||
if (!empty($data->merchantName)) { | ||
$googlePayConfig->setMerchantName($data->merchantName); | ||
} | ||
|
||
return $googlePayConfig; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
<?php | ||
|
||
namespace Pagarme\Core\Kernel\ValueObjects\Configuration; | ||
|
||
use Pagarme\Core\Kernel\Abstractions\AbstractValueObject; | ||
|
||
class GooglePayConfig extends AbstractValueObject | ||
{ | ||
private $enabled; | ||
private $title; | ||
private $merchantId; | ||
private $merchantName; | ||
|
||
/** | ||
* @param bool $enabled | ||
* @return GooglePayConfig | ||
*/ | ||
public function setEnabled($enabled) | ||
{ | ||
$this->enabled = $enabled; | ||
return $this; | ||
} | ||
|
||
/** | ||
* @param string $title | ||
* @return GooglePayConfig | ||
*/ | ||
public function setTitle($title) | ||
{ | ||
$this->title = $title; | ||
return $this; | ||
} | ||
|
||
/** | ||
* @param string $merchantId | ||
* @return GooglePayConfig | ||
*/ | ||
public function setMerchantId($merchantId) | ||
{ | ||
$this->merchantId = $merchantId; | ||
return $this; | ||
} | ||
|
||
/** | ||
* @param string $merchantId | ||
* @return GooglePayConfig | ||
*/ | ||
public function setMerchantName($merchantName) | ||
{ | ||
$this->merchantName = $merchantName; | ||
return $this; | ||
} | ||
|
||
protected function isEqual($object) | ||
{ | ||
return $this->enabled === $this->isEnabled() | ||
&& $this->title === $this->getTitle() | ||
&& $this->merchantName === $this->getMerchantName() | ||
&& $this->merchantId === $this->getMerchantId(); | ||
} | ||
|
||
public function isEnabled() | ||
{ | ||
return $this->enabled; | ||
} | ||
|
||
public function getTitle() | ||
{ | ||
return $this->title; | ||
} | ||
|
||
public function getMerchantName() | ||
{ | ||
return $this->merchantName; | ||
} | ||
|
||
public function getMerchantId() | ||
{ | ||
return $this->merchantId; | ||
} | ||
|
||
#[\ReturnTypeWillChange] | ||
public function jsonSerialize() | ||
{ | ||
return [ | ||
"enabled" => $this->isEnabled(), | ||
"title" => $this->getTitle(), | ||
"merchantId" => $this->getMerchantId(), | ||
"merchantName" => $this->getMerchantName(), | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.