Skip to content
This repository has been archived by the owner on Jul 3, 2021. It is now read-only.

Commit

Permalink
Apply fixes from StyleCI (#4)
Browse files Browse the repository at this point in the history
* Apply fixes from StyleCI

* Update README.md
  • Loading branch information
Ramy Talal committed Mar 7, 2018
1 parent 0d9b3a9 commit d141381
Show file tree
Hide file tree
Showing 14 changed files with 42 additions and 41 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE.md)
[![Build Status](https://img.shields.io/travis/RamyTalal/Exporter/master.svg?style=flat-square)](https://travis-ci.org/RamyTalal/Exporter)
[![Quality Score](https://img.shields.io/scrutinizer/g/RamyTalal/Exporter.svg?style=flat-square)](https://scrutinizer-ci.com/g/RamyTalal/Exporter)
[![StyleCI](https://styleci.io/repos/54327422/shield?branch=master)](https://styleci.io/repos/80513668)
[![StyleCI](https://styleci.io/repos/54327422/shield?branch=master)](https://styleci.io/repos/54327422)
[![Total Downloads](https://img.shields.io/packagist/dt/RamyTalal/Exporter.svg?style=flat-square)](https://packagist.org/packages/RamyTalal/Exporter)

Export the Laravel environment file to a capable web server format.
Expand Down
5 changes: 3 additions & 2 deletions src/Console/Command/Export.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

namespace Talal\Exporter\Console\Command;

use Talal\Exporter\Exporter;
use Illuminate\Console\Command;
use Illuminate\Filesystem\Filesystem;
use Talal\Exporter\Exporter;

class Export extends Command
{
Expand Down Expand Up @@ -46,7 +46,7 @@ public function __construct(Filesystem $filesystem)
public function handle()
{
$fileContents = $this->filesystem->get(
$this->laravel->basePath() . '/' . $this->option('file')
$this->laravel->basePath().'/'.$this->option('file')
);

$this->export($fileContents);
Expand All @@ -65,6 +65,7 @@ protected function export($fileContents)

if (! class_exists($server)) {
$this->error('The provided server is not exportable.');

return 0;
}

Expand Down
26 changes: 13 additions & 13 deletions src/Exporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,23 @@ public function __construct(Output $output)
$this->setOutput($output);
}

/**
* Set the output converter
*
* @param Output $output
*/
public function setOutput(Output $output)
/**
* Set the output converter.
*
* @param Output $output
*/
public function setOutput(Output $output)
{
$this->output = $output;
}

/**
* Return the converted environment variables
*
* @return string
*/
public function output() : string
/**
* Return the converted environment variables.
*
* @return string
*/
public function output() : string
{
return $this->output->generate();
}
}
}
4 changes: 2 additions & 2 deletions src/Output/Apache.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
class Apache extends Output
{
/**
* @inheritdoc
* {@inheritdoc}
*/
public function generate() : string
{
$output = '';

foreach ($this->keys as $key => $match) {
$output .= sprintf('SetEnv %s "%s"', $match, $this->values[$key]) . PHP_EOL;
$output .= sprintf('SetEnv %s "%s"', $match, $this->values[$key]).PHP_EOL;
}

return rtrim($output, PHP_EOL);
Expand Down
4 changes: 2 additions & 2 deletions src/Output/Bash.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
class Bash extends Output
{
/**
* @inheritdoc
* {@inheritdoc}
*/
public function generate() : string
{
$output = '';

foreach ($this->keys as $key => $match) {
$output .= sprintf('export %s="%s"', $match, $this->values[$key]) . PHP_EOL;
$output .= sprintf('export %s="%s"', $match, $this->values[$key]).PHP_EOL;
}

return rtrim($output, PHP_EOL);
Expand Down
2 changes: 1 addition & 1 deletion src/Output/Iis.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
class Iis extends Output
{
/**
* @inheritdoc
* {@inheritdoc}
*/
public function generate() : string
{
Expand Down
8 changes: 4 additions & 4 deletions src/Output/Lighttpd.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
class Lighttpd extends Output
{
/**
* @inheritdoc
* {@inheritdoc}
*/
public function generate() : string
{
Expand All @@ -15,9 +15,9 @@ public function generate() : string
$lines[] = sprintf("\t\"%s\" => \"%s\"", $match, $this->values[$key]);
}

$output = 'setenv.add-environment = (' . PHP_EOL;
$output .= implode(',' . PHP_EOL, $lines);
$output .= PHP_EOL . ')';
$output = 'setenv.add-environment = ('.PHP_EOL;
$output .= implode(','.PHP_EOL, $lines);
$output .= PHP_EOL.')';

return $output;
}
Expand Down
4 changes: 2 additions & 2 deletions src/Output/Nginx.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
class Nginx extends Output
{
/**
* @inheritdoc
* {@inheritdoc}
*/
public function generate() : string
{
$output = '';

foreach ($this->keys as $key => $match) {
$output .= sprintf('fastcgi_param %s "%s";', $match, $this->values[$key]) . PHP_EOL;
$output .= sprintf('fastcgi_param %s "%s";', $match, $this->values[$key]).PHP_EOL;
}

return rtrim($output, PHP_EOL);
Expand Down
6 changes: 3 additions & 3 deletions tests/ExporterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@

namespace Talal\Exporter\Tests;

use PHPUnit\Framework\TestCase;
use Talal\Exporter\Exporter;
use PHPUnit\Framework\TestCase;
use Talal\Exporter\Output\Nginx;

class ExporterTest extends TestCase
{
public function testHasValidEnvironment()
{
$fileContents = <<<EOF
$fileContents = <<<'EOF'
key1=value1
key2="value2"
EOF;

$exporter = new Exporter(new Nginx($fileContents));
$expected = <<<EOF
$expected = <<<'EOF'
fastcgi_param key1 "value1";
fastcgi_param key2 "value2";
EOF;
Expand Down
4 changes: 2 additions & 2 deletions tests/Output/ApacheTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ class ApacheTest extends TestCase
{
public function testGeneratedOutput()
{
$fileContents = <<<EOF
$fileContents = <<<'EOF'
key1=value1
key2="value2"
EOF;

$server = new Apache($fileContents);
$output = $server->generate();

$expected = <<<EOF
$expected = <<<'EOF'
SetEnv key1 "value1"
SetEnv key2 "value2"
EOF;
Expand Down
4 changes: 2 additions & 2 deletions tests/Output/BashTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ class BashTest extends TestCase
{
public function testGeneratedOutput()
{
$fileContents = <<<EOF
$fileContents = <<<'EOF'
key1=value1
key2="value2"
EOF;

$server = new Bash($fileContents);
$output = $server->generate();

$expected = <<<EOF
$expected = <<<'EOF'
export key1="value1"
export key2="value2"
EOF;
Expand Down
6 changes: 3 additions & 3 deletions tests/Output/IisTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,22 @@

namespace Talal\Exporter\Tests\Output;

use PHPUnit\Framework\TestCase;
use Talal\Exporter\Output\Iis;
use PHPUnit\Framework\TestCase;

class IisTest extends TestCase
{
public function testGeneratedOutput()
{
$fileContents = <<<EOF
$fileContents = <<<'EOF'
key1=value1
key2="value2"
EOF;

$server = new Iis($fileContents);
$output = $server->generate();

$expected = <<<EOF
$expected = <<<'EOF'
<environmentVariables>
<environmentVariable name="key1" value="value1"/>
<environmentVariable name="key2" value="value2"/>
Expand Down
4 changes: 2 additions & 2 deletions tests/Output/LighttpdTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ class LighttpdTest extends TestCase
{
public function testGeneratedOutput()
{
$fileContents = <<<EOF
$fileContents = <<<'EOF'
key1=value1
key2="value2"
EOF;

$server = new Lighttpd($fileContents);
$output = $server->generate();

$expected = <<<EOF
$expected = <<<'EOF'
setenv.add-environment = (
"key1" => "value1",
"key2" => "value2"
Expand Down
4 changes: 2 additions & 2 deletions tests/Output/NginxTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ class NginxTest extends TestCase
{
public function testGeneratedOutput()
{
$fileContents = <<<EOF
$fileContents = <<<'EOF'
key1=value1
key2="value2"
EOF;

$server = new Nginx($fileContents);
$output = $server->generate();

$expected = <<<EOF
$expected = <<<'EOF'
fastcgi_param key1 "value1";
fastcgi_param key2 "value2";
EOF;
Expand Down

0 comments on commit d141381

Please sign in to comment.