Skip to content

Commit

Permalink
Change class names
Browse files Browse the repository at this point in the history
  • Loading branch information
ksdev-pl committed Jul 5, 2015
1 parent bccb036 commit 80ebae0
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 28 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ $ composer require ksdev/nbp-currency-converter

``` php
use Ksdev\NBPCurrencyConverter\CurrencyConverter;
use Ksdev\NBPCurrencyConverter\ExRatesDayTableFinder;
use Ksdev\NBPCurrencyConverter\ExRatesDayTableFactory;
use Ksdev\NBPCurrencyConverter\ExRatesTableFinder;
use Ksdev\NBPCurrencyConverter\ExRatesTableFactory;
use GuzzleHttp\Client;

$converter = new CurrencyConverter(
new ExRatesDayTableFinder(
new ExRatesTableFinder(
new Client(),
new ExRatesDayTableFactory(),
new ExRatesTableFactory(),
'path/to/cache/folder'
)
);
Expand Down
4 changes: 2 additions & 2 deletions src/CurrencyConverter.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class CurrencyConverter
{
private $ratesTableFinder;

public function __construct(ExRatesDayTableFinder $ratesTableFinder)
public function __construct(ExRatesTableFinder $ratesTableFinder)
{
$this->ratesTableFinder = $ratesTableFinder;
}
Expand All @@ -22,7 +22,7 @@ public function __construct(ExRatesDayTableFinder $ratesTableFinder)
*/
public function averageExchangeRates(\DateTime $pubDate = null)
{
$ratesTable = $this->ratesTableFinder->getExRatesDayTable($pubDate);
$ratesTable = $this->ratesTableFinder->getExRatesTable($pubDate);
return $ratesTable->parsedContent;
}

Expand Down
2 changes: 1 addition & 1 deletion src/ExRatesDayTable.php → src/ExRatesTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Ksdev\NBPCurrencyConverter;

class ExRatesDayTable
class ExRatesTable
{
/** @var string */
public $rawContent;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@

namespace Ksdev\NBPCurrencyConverter;

class ExRatesDayTableFactory
class ExRatesTableFactory
{
/**
* Get new ExRatesDayTable
* Get new ExRatesTable
*
* @param string $rawContent Raw xml content
*
* @return ExRatesDayTable
* @return ExRatesTable
*/
public function getInstance($rawContent)
{
return new ExRatesDayTable($rawContent);
return new ExRatesTable($rawContent);
}
}
14 changes: 7 additions & 7 deletions src/ExRatesDayTableFinder.php → src/ExRatesTableFinder.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

namespace Ksdev\NBPCurrencyConverter;

class ExRatesDayTableFinder
class ExRatesTableFinder
{
const NBP_XML_URL = 'http://www.nbp.pl/kursy/xml/';
const MAX_ONE_TIME_API_REQ = 7;

/** @var \GuzzleHttp\Client */
private $guzzle;

/** @var ExRatesDayTableFactory */
/** @var ExRatesTableFactory */
private $ratesTableFactory;

/** @var string */
Expand All @@ -21,14 +21,14 @@ class ExRatesDayTableFinder

/**
* @param \GuzzleHttp\Client $guzzle
* @param ExRatesDayTableFactory $ratesTableFactory
* @param ExRatesTableFactory $ratesTableFactory
* @param string $cachePath Optional path to an existing folder where the cache files will be stored
*
* @throws \Exception
*/
public function __construct(
\GuzzleHttp\Client $guzzle,
ExRatesDayTableFactory $ratesTableFactory,
ExRatesTableFactory $ratesTableFactory,
$cachePath = ''
) {
$this->guzzle = $guzzle;
Expand All @@ -42,15 +42,15 @@ public function __construct(
}

/**
* Get the ExRatesDayTable instance
* Get the ExRatesTable instance
*
* @param \DateTime $pubDate Optional rates table publication date
*
* @return ExRatesDayTable
* @return ExRatesTable
*
* @throws \Exception
*/
public function getExRatesDayTable(\DateTime $pubDate = null)
public function getExRatesTable(\DateTime $pubDate = null)
{
$this->setSoughtPubDate($pubDate);

Expand Down
20 changes: 10 additions & 10 deletions tests/CurrencyConverterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
namespace Ksdev\NBPCurrencyConverter\Test;

use Ksdev\NBPCurrencyConverter\CurrencyConverter;
use Ksdev\NBPCurrencyConverter\ExRatesDayTableFactory;
use Ksdev\NBPCurrencyConverter\ExRatesDayTableFinder;
use Ksdev\NBPCurrencyConverter\ExRatesTableFactory;
use Ksdev\NBPCurrencyConverter\ExRatesTableFinder;
use Mockery;

class CurrencyConverterTest extends \PHPUnit_Framework_TestCase
Expand Down Expand Up @@ -39,7 +39,7 @@ public function guzzleMock()

public function testConvert()
{
$converter = new CurrencyConverter(new ExRatesDayTableFinder($this->guzzleMock(), new ExRatesDayTableFactory()));
$converter = new CurrencyConverter(new ExRatesTableFinder($this->guzzleMock(), new ExRatesTableFactory()));
$pubDate = new \DateTime('2015-07-03');

$this->assertEquals('0.2651', $converter->convert('1.0000', 'PLN', 'USD', $pubDate)['amount']);
Expand All @@ -64,7 +64,7 @@ public function testConvert()

public function testInvalidPublicationDate()
{
$converter = new CurrencyConverter(new ExRatesDayTableFinder($this->guzzleMock(), new ExRatesDayTableFactory()));
$converter = new CurrencyConverter(new ExRatesTableFinder($this->guzzleMock(), new ExRatesTableFactory()));

$numExceptions = 0;
try {
Expand All @@ -87,7 +87,7 @@ public function testInvalidPublicationDate()

public function testInvalidFormatOfAmount()
{
$converter = new CurrencyConverter(new ExRatesDayTableFinder($this->guzzleMock(), new ExRatesDayTableFactory()));
$converter = new CurrencyConverter(new ExRatesTableFinder($this->guzzleMock(), new ExRatesTableFactory()));
$pubDate = new \DateTime('2015-07-03');

$numExceptions = 0;
Expand Down Expand Up @@ -125,7 +125,7 @@ public function testInvalidFormatOfAmount()
*/
public function testInvalidCurrencyCode()
{
$converter = new CurrencyConverter(new ExRatesDayTableFinder($this->guzzleMock(), new ExRatesDayTableFactory()));
$converter = new CurrencyConverter(new ExRatesTableFinder($this->guzzleMock(), new ExRatesTableFactory()));
$pubDate = new \DateTime('2015-07-03');

$converter->convert('123.4567', 'ABC', 'USD', $pubDate);
Expand All @@ -137,7 +137,7 @@ public function testInvalidCurrencyCode()
*/
public function testInvalidCachePath()
{
new CurrencyConverter(new ExRatesDayTableFinder($this->guzzleMock(), new ExRatesDayTableFactory(), '/this/folder/doesnotexist'));
new CurrencyConverter(new ExRatesTableFinder($this->guzzleMock(), new ExRatesTableFactory(), '/this/folder/doesnotexist'));
}

/**
Expand Down Expand Up @@ -168,7 +168,7 @@ public function testInvalidXml()
->andReturn($dirMock)
->mock();

$converter = new CurrencyConverter(new ExRatesDayTableFinder($guzzleMock, new ExRatesDayTableFactory()));
$converter = new CurrencyConverter(new ExRatesTableFinder($guzzleMock, new ExRatesTableFactory()));
$pubDate = new \DateTime('2015-07-03');
$converter->convert('123.4567', 'PLN', 'USD', $pubDate);
}
Expand All @@ -188,7 +188,7 @@ public function testInvalidResponseStatusCode()
->andReturn('A good reason')
->mock();

$converter = new CurrencyConverter(new ExRatesDayTableFinder($guzzleMock, new ExRatesDayTableFactory()));
$converter = new CurrencyConverter(new ExRatesTableFinder($guzzleMock, new ExRatesTableFactory()));
$converter->convert('123.4567', 'PLN', 'USD');
}

Expand Down Expand Up @@ -223,7 +223,7 @@ public function testCache()
->andReturn($dirMock)
->mock();

$converter = new CurrencyConverter(new ExRatesDayTableFinder($guzzleMock, new ExRatesDayTableFactory(), __DIR__));
$converter = new CurrencyConverter(new ExRatesTableFinder($guzzleMock, new ExRatesTableFactory(), __DIR__));
$pubDate = new \DateTime('2015-07-03');
$converter->convert('123.4567', 'PLN', 'USD', $pubDate);

Expand Down

0 comments on commit 80ebae0

Please sign in to comment.