-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor config array to public Config service
- Loading branch information
Showing
8 changed files
with
320 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Guave\DeeplBundle\Config; | ||
|
||
class Config | ||
{ | ||
private bool $enabled = false; | ||
|
||
private bool $freeApi = false; | ||
|
||
private string $defaultLanguage = 'de'; | ||
|
||
private array $tables = []; | ||
|
||
public function __construct(array $config) | ||
{ | ||
if (isset($config['enabled'])) { | ||
$this->setEnabled($config['enabled']); | ||
} | ||
if (isset($config['freeApi'])) { | ||
$this->setFreeApi($config['freeApi']); | ||
} | ||
if (isset($config['defaultLanguage'])) { | ||
$this->setDefaultLanguage($config['defaultLanguage']); | ||
} | ||
if (isset($config['tables'])) { | ||
$this->setTables($config['tables']); | ||
} | ||
} | ||
|
||
public function isEnabled(): bool | ||
{ | ||
return $this->enabled; | ||
} | ||
|
||
public function setEnabled(bool $enabled): void | ||
{ | ||
$this->enabled = $enabled; | ||
} | ||
|
||
public function isFreeApi(): bool | ||
{ | ||
return $this->freeApi; | ||
} | ||
|
||
public function setFreeApi(bool $freeApi): void | ||
{ | ||
$this->freeApi = $freeApi; | ||
} | ||
|
||
public function getDefaultLanguage(): string | ||
{ | ||
return $this->defaultLanguage; | ||
} | ||
|
||
public function setDefaultLanguage(string $defaultLanguage): void | ||
{ | ||
$this->defaultLanguage = $defaultLanguage; | ||
} | ||
|
||
public function getTables(): array | ||
{ | ||
return $this->tables; | ||
} | ||
|
||
public function setTables(array $tables): void | ||
{ | ||
$this->tables = $tables; | ||
} | ||
|
||
public function getDeeplConfigByTable(string $table): array | ||
{ | ||
$tables = $this->getTables(); | ||
|
||
return $tables[$table] ?? []; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.