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:
Oliver Davies 2020-05-29 13:26:26 +01:00
parent 4db74ad058
commit e5268e9707
4 changed files with 78 additions and 1 deletions

2
.gitignore vendored
View file

@ -2,3 +2,5 @@
!*/
!/.gitignore
!/composer.json
!/src/**
!/tests/**

View file

@ -9,5 +9,18 @@
}
],
"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
View 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;
}
}

View 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());
}
}