mirror of
https://github.com/opdavies/glassboxx-sdk-php.git
synced 2025-02-17 22:50:48 +00:00
Add the Config class
Add a Config class for storing configuration values such as the Glassboxx username, password and vendor ID.
This commit is contained in:
parent
4db74ad058
commit
e5268e9707
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -2,3 +2,5 @@
|
||||||
!*/
|
!*/
|
||||||
!/.gitignore
|
!/.gitignore
|
||||||
!/composer.json
|
!/composer.json
|
||||||
|
!/src/**
|
||||||
|
!/tests/**
|
||||||
|
|
|
@ -9,5 +9,18 @@
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"minimum-stability": "stable",
|
"minimum-stability": "stable",
|
||||||
"require": {}
|
"require": {},
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"Opdavies\\Glassboxx\\": "src/Glassboxx/"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"autoload-dev": {
|
||||||
|
"psr-4": {
|
||||||
|
"Opdavies\\Glassboxx\\Tests\\": "tests/"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"phpunit/phpunit": "^9.1"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
40
src/Glassboxx/Config.php
Normal file
40
src/Glassboxx/Config.php
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Opdavies\Glassboxx;
|
||||||
|
|
||||||
|
class Config
|
||||||
|
{
|
||||||
|
/** @var int $vendorId */
|
||||||
|
private $vendorId;
|
||||||
|
|
||||||
|
/** @var string $username */
|
||||||
|
private $username;
|
||||||
|
|
||||||
|
/** @var string $password */
|
||||||
|
private $password;
|
||||||
|
|
||||||
|
public function __construct(
|
||||||
|
int $vendorId,
|
||||||
|
string $username,
|
||||||
|
string $password
|
||||||
|
) {
|
||||||
|
$this->password = $password;
|
||||||
|
$this->username = $username;
|
||||||
|
$this->vendorId = $vendorId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getPassword(): string
|
||||||
|
{
|
||||||
|
return $this->password;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getUsername(): string
|
||||||
|
{
|
||||||
|
return $this->username;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getVendorId(): int
|
||||||
|
{
|
||||||
|
return $this->vendorId;
|
||||||
|
}
|
||||||
|
}
|
22
tests/Glassboxx/ConfigTest.php
Normal file
22
tests/Glassboxx/ConfigTest.php
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Opdavies\Glassboxx\Tests\Glassboxx;
|
||||||
|
|
||||||
|
use Opdavies\Glassboxx\Config;
|
||||||
|
use PHPUnit\Framework\TestCase;
|
||||||
|
|
||||||
|
class ConfigTest extends TestCase
|
||||||
|
{
|
||||||
|
public function testThatGettersReturnExpectedValues(): void
|
||||||
|
{
|
||||||
|
$config = new Config(
|
||||||
|
12345,
|
||||||
|
'opdavies',
|
||||||
|
'secret'
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->assertSame(12345, $config->getVendorId());
|
||||||
|
$this->assertSame('opdavies', $config->getUsername());
|
||||||
|
$this->assertSame('secret', $config->getPassword());
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue