Skip to content

Commit

Permalink
v1.0.0-pre.2
Browse files Browse the repository at this point in the history
  • Loading branch information
attogram committed Apr 13, 2019
1 parent 13f4637 commit f5ad4e1
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 13 deletions.
4 changes: 3 additions & 1 deletion cli/update.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,6 @@
die($code . ' API Endpoint Not Found');
}

new $class($api, true);
$verbosity = 0;

new $class($api, $verbosity);
2 changes: 1 addition & 1 deletion src/CurrencyExchangeRates.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class CurrencyExchangeRates
use CustomizationTrait;

/** @var string Version*/
const VERSION = '1.0.0-pre.1';
const VERSION = '1.0.0-pre.2';

/** @var Database|null */
protected $database;
Expand Down
34 changes: 23 additions & 11 deletions src/Feeds/Feed.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,31 +24,43 @@ class Feed implements FeedsInterface
/** @var array */
protected $data = [];

/** @var int */
protected $verbosity = 0;

/**
* Feed constructor.
* @param string $api
* @param bool $silent
* @param int $verbosity
* @throws Exception
* @throws GuzzleException
*/
public function __construct(string $api, bool $silent = false)
public function __construct(string $api, int $verbosity = 1)
{
$this->api = $api;
print ($silent ? '' : "\n\nGetting feed: " . $this->api);
$this->verbosity = $verbosity;
$this->verbose("\n\nGetting feed: " . $this->api);
$this->get();
print ($silent ? '' : "\n\nGot " . strlen($this->raw) . " characters\n")
. ($silent ? '' : '<textarea rows="5" cols="100">' . $this->raw . '</textarea>');
$this->verbose("\n\nGot " . strlen($this->raw) . " characters\n");
$this->verbose('<textarea rows="5" cols="100">' . $this->raw . '</textarea>');
$this->transform();
print ($silent ? '' : "\n\nTransformed to " . strlen($this->raw) . " characters\n")
. ($silent ? '' : '<textarea rows="5" cols="100">' . $this->raw . '</textarea>');
$this->verbose("\n\nTransformed to " . strlen($this->raw) . " characters\n");
$this->verbose('<textarea rows="5" cols="100">' . $this->raw . '</textarea>');
$this->process();
print ($silent ? '' : "\n\nProcessed " . count($this->lines) . " lines\n")
. ($silent ? '' : '<textarea rows="5" cols="100">' . print_r($this->lines, true) . '</textarea>');
$this->verbose("\n\nProcessed " . count($this->lines) . " lines\n");
$this->verbose('<textarea rows="5" cols="100">' . print_r($this->lines, true) . '</textarea>');
$this->insert();
print ($silent ? '' : "\n\nInserted " . count($this->data) . " entries\n")
. ($silent ? '' : '<textarea rows="10" cols="100">' . print_r($this->data, true) . '</textarea>');
$this->verbose("\n\nInserted " . count($this->data) . " entries\n");
$this->verbose('<textarea rows="10" cols="100">' . print_r($this->data, true) . '</textarea>');
}

/**
* @param string $text
*/
public function verbose(string $text) {
if ($this->verbosity > 0) {
print $text;
}
}
/**
* Get the feed into $this->raw
*
Expand Down

0 comments on commit f5ad4e1

Please sign in to comment.