path = $path; $this->account = new NullAccount(); $this->createdAt = new \DateTimeImmutable(); $this->source = new NullCollection(); } /** * Load info data from path. * * @return void * * @throws PathException this exception is thrown in case the info file path doesn't exist * * @since 1.0.0 */ public function load() : void { if (!\is_file($this->path)) { throw new PathException($this->path); } $contents = \file_get_contents($this->path); $info = \json_decode($contents === false ? '[]' : $contents, true); $this->title = $info['name']; $this->version = $info['version']; $this->website = $info['website']; $this->hasExport = $info['export']; $this->hasImport = $info['import']; } /** * Get info path * * @return string * * @since 1.0.0 */ public function getPath() : string { return $this->path; } /** * Get id * * @return int * * @since 1.0.0 */ public function getId() : int { return $this->id; } /** * Get settings. * * @return ExchangeSetting[] * * @since 1.0.0 */ public function getSettings() : array { return $this->settings; } /** * Adding new setting. * * @param ExchangeSetting $setting Setting * * @return int * * @since 1.0.0 */ public function addSetting(ExchangeSetting $setting) : int { $this->settings[] = $setting; \end($this->settings); $key = (int) \key($this->settings); \reset($this->settings); return $key; } }