Skip to content

Commit

Permalink
- Made definitions.json source configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexanderBuzz committed Dec 21, 2023
1 parent 06ab95f commit d2cf8ea
Show file tree
Hide file tree
Showing 3 changed files with 2,518 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/Core/RippleBinaryCodec/Definitions/Definitions.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace XRPL_PHP\Core\RippleBinaryCodec\Definitions;

use Exception;

class Definitions
{
public static ?Definitions $instance = null;
Expand All @@ -22,10 +24,21 @@ class Definitions

private array $fieldIdNameMap = [];

/**
* Definitions constructor.
*
* @throws Exception
*/
public function __construct()
{
$path = dirname(__FILE__) . "/definitions.json";
$this->definitions = json_decode(file_get_contents($path), true);
$path = getenv('XRPL_PHP_DEFINITIONS_FILE_PATH') ?: dirname(__FILE__) . "/definitions.json";
if (file_exists($path)) {
$fileContents = file_get_contents($path);
} else {
throw new Exception("Definitions file not found.");
}

$this->definitions = json_decode($fileContents, true);

$this->typeOrdinals = $this->definitions['TYPES'];
$this->ledgerEntryTypes = $this->definitions['LEDGER_ENTRY_TYPES'];
Expand Down
Loading

0 comments on commit d2cf8ea

Please sign in to comment.