Skip to content

Commit

Permalink
fix namespace issue move to Adaa
Browse files Browse the repository at this point in the history
  • Loading branch information
Elteyab Hassan authored and Elteyab Hassan committed Sep 4, 2022
1 parent f83e159 commit 1ed0052
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 24 deletions.
3 changes: 1 addition & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ os:
- linux

php:
- 5.6
- 7.3
- 8.1

script:
- vendor/phpunit/phpunit/phpunit
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@
},
"autoload": {
"psr-4": {
"MartinLindhe\\VueInternationalizationGenerator\\": "src/"
"Adaa\\VueInternationalizationGenerator\\": "src/"
}
},
"extra": {
"laravel": {
"providers": [
"MartinLindhe\\VueInternationalizationGenerator\\GeneratorProvider"
"Adaa\\VueInternationalizationGenerator\\GeneratorProvider"
]
}
}
Expand Down
4 changes: 3 additions & 1 deletion src/Commands/GenerateInclude.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php namespace MartinLindhe\VueInternationalizationGenerator\Commands;
<?php

namespace Adaa\VueInternationalizationGenerator\Commands;

use Illuminate\Console\Command;

Expand Down
24 changes: 13 additions & 11 deletions src/Generator.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php namespace MartinLindhe\VueInternationalizationGenerator;
<?php

namespace Adaa\VueInternationalizationGenerator;

use App;
use Exception;
Expand Down Expand Up @@ -54,13 +56,13 @@ public function generateFromPath($path, $format = 'es6', $withVendor = false, $l
$dirList = $this->getDirList($path);
$jsBody = '';
foreach ($dirList as $file) {
if(!$withVendor
&& in_array($file, array_merge(['vendor'], $this->config['excludes']))
) {
continue;
}
if (!$withVendor
&& in_array($file, array_merge(['vendor'], $this->config['excludes']))
) {
continue;
}

$files[] = $path . DIRECTORY_SEPARATOR . $file;
$files[] = $path . DIRECTORY_SEPARATOR . $file;
}

foreach ($files as $fileName) {
Expand Down Expand Up @@ -92,7 +94,7 @@ public function generateFromPath($path, $format = 'es6', $withVendor = false, $l
$jsonLocales = json_encode($locales, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) . PHP_EOL;

if (json_last_error() !== JSON_ERROR_NONE) {
throw new Exception('Could not generate JSON, error code '.json_last_error());
throw new Exception('Could not generate JSON, error code ' . json_last_error());
}

// formats other than 'es6' and 'umd' will become plain JSON
Expand Down Expand Up @@ -155,7 +157,7 @@ public function generateMultiple($path, $format = 'es6', $multiLocales = false)
$createdFiles .= $fileToCreate . PHP_EOL;
$jsonLocales = json_encode($data, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) . PHP_EOL;
if (json_last_error() !== JSON_ERROR_NONE) {
throw new Exception('Could not generate JSON, error code '.json_last_error());
throw new Exception('Could not generate JSON, error code ' . json_last_error());
}
if ($format === 'es6') {
$jsBody = $this->getES6Module($jsonLocales);
Expand Down Expand Up @@ -228,7 +230,7 @@ private function allocateLocaleArray($path, $multiLocales = false)
if ($lastLocale !== false) {
$root = realpath(base_path() . $this->config['langPath'] . DIRECTORY_SEPARATOR . $lastLocale);
$filePath = $this->removeExtension(str_replace('\\', '_', ltrim(str_replace($root, '', realpath($fileName)), '\\')));
if($filePath[0] === DIRECTORY_SEPARATOR) {
if ($filePath[0] === DIRECTORY_SEPARATOR) {
$filePath = substr($filePath, 1);
}
if ($multiLocales) {
Expand Down Expand Up @@ -256,7 +258,7 @@ private function shouldIgnoreLangFile($noExt)
}

return (isset($this->config['langFiles']) && !empty($this->config['langFiles']) && !in_array($noExt, $this->config['langFiles']))
|| (isset($this->config['excludes']) && in_array($noExt, $this->config['excludes']));
|| (isset($this->config['excludes']) && in_array($noExt, $this->config['excludes']));
}

/**
Expand Down
9 changes: 5 additions & 4 deletions src/GeneratorProvider.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php namespace MartinLindhe\VueInternationalizationGenerator;
<?php
namespace Adaa\VueInternationalizationGenerator;

use Illuminate\Support\ServiceProvider;

Expand Down Expand Up @@ -27,11 +28,11 @@ public function boot()
);

$this->publishes([
__DIR__.'/config/vue-i18n-generator.php' => config_path('vue-i18n-generator.php'),
__DIR__ . '/config/vue-i18n-generator.php' => config_path('vue-i18n-generator.php'),
]);

$this->mergeConfigFrom(
__DIR__.'/config/vue-i18n-generator.php',
$this->mergeConfigFrom(
__DIR__ . '/config/vue-i18n-generator.php',
'vue-i18n-generator'
);
}
Expand Down
4 changes: 2 additions & 2 deletions tests/MultiFileGeneratorTest.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

use MartinLindhe\VueInternationalizationGenerator\Generator;
use Adaa\VueInternationalizationGenerator\Generator;


class MultiFileGeneratorTest extends \Orchestra\Testbench\TestCase
Expand Down Expand Up @@ -45,7 +45,7 @@ private function evaluateMultiOutput($input, $expected, $format = 'es6', $multiL

$expectedFiles = [];

foreach($expected as $path => $file) {
foreach ($expected as $path => $file) {
$resultFile = $outDir . $file->getFilename();
$expectedFiles[] = $resultFile . PHP_EOL;
$this->assertEquals(
Expand Down
4 changes: 2 additions & 2 deletions tests/SingleFileGeneratorTest.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

use MartinLindhe\VueInternationalizationGenerator\Generator;
use Adaa\VueInternationalizationGenerator\Generator;

class SingleFileGeneratorTest extends \Orchestra\Testbench\TestCase
{
Expand Down Expand Up @@ -47,7 +47,7 @@ function testInvalidFormat()

try {
(new Generator([]))->generateFromPath($inputDir, $format);
} catch(RuntimeException $e) {
} catch (RuntimeException $e) {
$this->assertEquals('Invalid format passed: ' . $format, $e->getMessage());
return;
}
Expand Down

0 comments on commit 1ed0052

Please sign in to comment.