Skip to content

Commit

Permalink
apply php cs fixer files
Browse files Browse the repository at this point in the history
  • Loading branch information
boxblinkracer committed Dec 21, 2023
1 parent af7208c commit cc0af42
Show file tree
Hide file tree
Showing 192 changed files with 197 additions and 546 deletions.
3 changes: 1 addition & 2 deletions src/AppManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ class AppManager

/**
* @param array<mixed> $arguments
* @return void
* @throws Exception
* @return void
*/
public static function run(array $arguments): void
{
Expand All @@ -38,5 +38,4 @@ public static function run(array $arguments): void

$application->run();
}

}
7 changes: 3 additions & 4 deletions src/Bundles/Exchange/CSV/CSVExchange.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ public function setOptionValues(array $options): void
* @param TranslationSet $set
* @param string $outputDir
* @param bool $onlyEmpty
* @return void
* @throws TranslationNotFoundException
* @return void
*/
public function export(TranslationSet $set, string $outputDir, bool $onlyEmpty): void
{
Expand All @@ -81,13 +81,12 @@ public function export(TranslationSet $set, string $outputDir, bool $onlyEmpty):

/**
* @param string $filename
* @return ImportResult
* @throws Exception
* @return ImportResult
*/
public function import(string $filename): ImportResult
{
$importer = new CSVImporter($this->csvDelimiter);
return $importer->import($filename);
}

}
}
7 changes: 1 addition & 6 deletions src/Bundles/Exchange/CSV/Services/CSVExporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ public function __construct(CSVWriterInterface $csvWriter, string $delimiter)
* @param TranslationSet $set
* @param string $outputDir
* @param bool $onlyEmpty
* @return void
* @throws TranslationNotFoundException
* @return void
*/
public function export(TranslationSet $set, string $outputDir, bool $onlyEmpty): void
{
Expand Down Expand Up @@ -72,11 +72,9 @@ public function export(TranslationSet $set, string $outputDir, bool $onlyEmpty):
# BUILD DATA LINES

foreach ($set->getAllTranslationIDs() as $id) {

$keyRow = [];

if ($onlyEmpty) {

$isComplete = $set->isCompletelyTranslated($id);

# if it's already complete, do not export
Expand All @@ -101,7 +99,6 @@ public function export(TranslationSet $set, string $outputDir, bool $onlyEmpty):

# use the same sorting as our header line
foreach ($sortedLanguagesColumns as $colName) {

foreach ($set->getLocales() as $locale) {

# only use the one from our current column
Expand All @@ -116,7 +113,6 @@ public function export(TranslationSet $set, string $outputDir, bool $onlyEmpty):
$trans = $locale->findTranslation($id);

$keyRow[] = $trans->getValue();

} catch (TranslationNotFoundException $ex) {
# if we have no translation, add an empty value
$keyRow[] = '';
Expand Down Expand Up @@ -154,5 +150,4 @@ public function export(TranslationSet $set, string $outputDir, bool $onlyEmpty):

echo ' [+] generated file: ' . $csvFilename . PHP_EOL . PHP_EOL;
}

}
8 changes: 1 addition & 7 deletions src/Bundles/Exchange/CSV/Services/CSVImporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

class CSVImporter
{

use StringTrait;


Expand All @@ -30,8 +29,8 @@ public function __construct(string $delimiter)

/**
* @param string $filename
* @return ImportResult
* @throws Exception
* @return ImportResult
*/
public function import(string $filename): ImportResult
{
Expand All @@ -45,12 +44,10 @@ public function import(string $filename): ImportResult
}

while ($row = fgetcsv($csvFile, 0, $this->delimiter)) {

if ($headerFiles === []) {
# header line
$headerFiles = $row;
} else {

$startIndex = 1;

if (in_array('Group', $headerFiles)) {
Expand All @@ -63,13 +60,11 @@ public function import(string $filename): ImportResult
}

for ($i = $startIndex; $i <= count($row) - 1; $i++) {

$value = $row[$i];

$localeExchangeID = (string)$headerFiles[$i];

if ($localeExchangeID !== '') {

$importData[] = new ImportEntry(
$localeExchangeID,
(string)$key,
Expand All @@ -85,5 +80,4 @@ public function import(string $filename): ImportResult

return new ImportResult($importData);
}

}
3 changes: 1 addition & 2 deletions src/Bundles/Exchange/CSV/Services/CSVWriter.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,4 @@ public function close($file): void
{
fclose($file);
}

}
}
3 changes: 1 addition & 2 deletions src/Bundles/Exchange/CSV/Services/CSVWriterInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,4 @@ public function writeLine($file, array $row, string $delimiter): void;
* @return void
*/
public function close($file): void;

}
}
6 changes: 2 additions & 4 deletions src/Bundles/Exchange/ExchangeFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ private function __construct()

/**
* @param ExchangeInterface $exchangeFormat
* @return void
* @throws ConfigurationException
* @return void
*/
public function registerExchangeFormat(ExchangeInterface $exchangeFormat): void
{
Expand Down Expand Up @@ -94,8 +94,8 @@ public function getAllOptions(): array
/**
* @param string $format
* @param array<mixed> $options
* @return ExchangeInterface
* @throws Exception
* @return ExchangeInterface
*/
public function getExchange(string $format, array $options): ExchangeInterface
{
Expand All @@ -104,7 +104,6 @@ public function getExchange(string $format, array $options): ExchangeInterface
}

foreach ($this->exchangeServices as $exchangeService) {

if ($exchangeService->getName() === $format) {
$exchangeService->setOptionValues($options);

Expand All @@ -114,5 +113,4 @@ public function getExchange(string $format, array $options): ExchangeInterface

throw new Exception('No Exchange service found for format: ' . $format);
}

}
3 changes: 1 addition & 2 deletions src/Bundles/Exchange/ExchangeFormat.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,4 @@ class ExchangeFormat
*
*/
public const HTML = 'html';

}
}
3 changes: 1 addition & 2 deletions src/Bundles/Exchange/ExchangeInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,4 @@ public function export(TranslationSet $set, string $outputDir, bool $onlyEmpty):
* @return ImportResult
*/
public function import(string $filename): ImportResult;

}
}
7 changes: 3 additions & 4 deletions src/Bundles/Exchange/HTML/HTMLExchange.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ public function setOptionValues(array $options): void
* @param TranslationSet $set
* @param string $outputDir
* @param bool $onlyEmpty
* @return void
* @throws TranslationNotFoundException
* @return void
*/
public function export(TranslationSet $set, string $outputDir, bool $onlyEmpty): void
{
Expand All @@ -54,13 +54,12 @@ public function export(TranslationSet $set, string $outputDir, bool $onlyEmpty):

/**
* @param string $filename
* @return ImportResult
* @throws Exception
* @return ImportResult
*/
public function import(string $filename): ImportResult
{
$importer = new HTMLImporter();
return $importer->import($filename);
}

}
}
13 changes: 2 additions & 11 deletions src/Bundles/Exchange/HTML/Services/HTMLExporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ class HTMLExporter
* @param TranslationSet $set
* @param string $outputDir
* @param bool $onlyEmpty
* @return void
* @throws TranslationNotFoundException
* @return void
*/
public function export(TranslationSet $set, string $outputDir, bool $onlyEmpty): void
{
Expand Down Expand Up @@ -87,10 +87,7 @@ public function export(TranslationSet $set, string $outputDir, bool $onlyEmpty):
$previosuGroup = '';

foreach ($set->getAllTranslationIDs() as $id) {


if ($onlyEmpty) {

$isComplete = $set->isCompletelyTranslated($id);

# if it's already complete, do not export
Expand All @@ -103,7 +100,6 @@ public function export(TranslationSet $set, string $outputDir, bool $onlyEmpty):


foreach ($set->getLocales() as $locale) {

$translation = $locale->findTranslation($id);

if ($set->hasGroups()) {
Expand All @@ -122,8 +118,6 @@ public function export(TranslationSet $set, string $outputDir, bool $onlyEmpty):


foreach ($set->getLocales() as $locale) {


$value = $this->getTranslationValue($locale, $id);

$value = htmlentities($value);
Expand Down Expand Up @@ -168,7 +162,6 @@ class="translation textfield ' . $wasEmpty . '"
file_put_contents($fullFile, $html);

echo ' [+] generated file: ' . $fullFile . PHP_EOL . PHP_EOL;

}

/**
Expand All @@ -179,9 +172,7 @@ class="translation textfield ' . $wasEmpty . '"
private function getTranslationValue(Locale $locale, string $key): string
{
foreach ($locale->getTranslations() as $translation) {

if ($translation->getID() === $key) {

return $translation->getValue();
}
}
Expand Down Expand Up @@ -333,4 +324,4 @@ function updateTextfieldStyle(input) {
</script>
';
}
}
}
5 changes: 1 addition & 4 deletions src/Bundles/Exchange/HTML/Services/HTMLImporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

class HTMLImporter
{

use StringTrait;

/**
Expand All @@ -24,7 +23,6 @@ public function import(string $filename): ImportResult
$groupNameService = new GroupNameService();

foreach (new SplFileObject($filename) as $line) {

if ($line === false) {
$line = '';
}
Expand Down Expand Up @@ -63,5 +61,4 @@ public function import(string $filename): ImportResult

return new ImportResult($foundData);
}

}
}
1 change: 0 additions & 1 deletion src/Bundles/Exchange/ImportEntry.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,5 +71,4 @@ public function getValue(): string
{
return $this->value;
}

}
1 change: 0 additions & 1 deletion src/Bundles/Exchange/ImportResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,4 @@ public function getEntries(): array
{
return $this->entries;
}

}
6 changes: 1 addition & 5 deletions src/Bundles/Storage/INI/IniStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,29 +69,26 @@ public function configureStorage(TranslationSet $set): void

/**
* @param TranslationSet $set
* @return void
* @throws Exception
* @return void
*/
public function loadTranslationSet(TranslationSet $set): void
{
foreach ($set->getLocales() as $locale) {

$iniArray = parse_ini_file($locale->getFilename(), true, INI_SCANNER_RAW);

if ($iniArray === false) {
throw new Exception('Error when loading INI file: ' . $locale->getFilename());
}

foreach ($iniArray as $key => $value) {

if (is_array($value)) {
# we have a section
if ($key === $locale->getIniSection()) {
foreach ($value as $transKey => $transValue) {
$locale->addTranslation($transKey, $transValue, '');
}
}

} else {
# we just have a plain value
$locale->addTranslation($key, $value, '');
Expand Down Expand Up @@ -189,5 +186,4 @@ public function buildFileContentBuffer(Locale $locale, array &$contentBuffer, st

return $translationCount;
}

}
3 changes: 1 addition & 2 deletions src/Bundles/Storage/JSON/JsonStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ public function configureStorage(TranslationSet $set): void

/**
* @param TranslationSet $set
* @return void
* @throws Exception
* @return void
*/
public function loadTranslationSet(TranslationSet $set): void
{
Expand Down Expand Up @@ -122,5 +122,4 @@ public function saveTranslationLocale(Locale $locale, string $filename): Storage

return new StorageSaveResult(1, $translationsCount);
}

}
Loading

0 comments on commit cc0af42

Please sign in to comment.