Skip to content

Commit

Permalink
PSR-2
Browse files Browse the repository at this point in the history
  • Loading branch information
Gravitano committed May 18, 2015
1 parent 00fee2a commit 869bc9c
Show file tree
Hide file tree
Showing 141 changed files with 1,172 additions and 1,394 deletions.
5 changes: 3 additions & 2 deletions src/Pingpong/Generators/Console/ConsoleCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputOption;

class ConsoleCommand extends Command {
class ConsoleCommand extends Command
{

/**
* The name of command.
Expand Down Expand Up @@ -67,4 +68,4 @@ public function getOptions()
['force', 'f', InputOption::VALUE_NONE, 'Force the creation if file already exists.', null],
];
}
}
}
5 changes: 3 additions & 2 deletions src/Pingpong/Generators/Console/ControllerCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputOption;

class ControllerCommand extends Command {
class ControllerCommand extends Command
{

/**
* The name of command.
Expand Down Expand Up @@ -67,4 +68,4 @@ public function getOptions()
['force', 'f', InputOption::VALUE_NONE, 'Force the creation if file already exists.', null],
];
}
}
}
5 changes: 3 additions & 2 deletions src/Pingpong/Generators/Console/FormCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputOption;

class FormCommand extends Command {
class FormCommand extends Command
{

/**
* The name of command.
Expand Down Expand Up @@ -61,4 +62,4 @@ public function getOptions()
['fields', 'f', InputOption::VALUE_OPTIONAL, 'The form fields.', null],
];
}
}
}
5 changes: 3 additions & 2 deletions src/Pingpong/Generators/Console/MigrationCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputOption;

class MigrationCommand extends Command {
class MigrationCommand extends Command
{

/**
* The name of command.
Expand Down Expand Up @@ -68,4 +69,4 @@ public function getOptions()
['force', 'f', InputOption::VALUE_NONE, 'Force the creation if file already exists.', null],
];
}
}
}
5 changes: 3 additions & 2 deletions src/Pingpong/Generators/Console/ModelCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputOption;

class ModelCommand extends Command {
class ModelCommand extends Command
{

/**
* The name of command.
Expand Down Expand Up @@ -65,4 +66,4 @@ public function getOptions()
['force', 'f', InputOption::VALUE_NONE, 'Force the creation if file already exists.', null],
];
}
}
}
5 changes: 3 additions & 2 deletions src/Pingpong/Generators/Console/PivotCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputOption;

class PivotCommand extends Command {
class PivotCommand extends Command
{

/**
* The name of command.
Expand Down Expand Up @@ -67,4 +68,4 @@ public function getOptions()
['force', 'f', InputOption::VALUE_NONE, 'Force the creation if file already exists.', null],
];
}
}
}
6 changes: 3 additions & 3 deletions src/Pingpong/Generators/Console/RequestCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputOption;

class RequestCommand extends Command {
class RequestCommand extends Command
{

/**
* The name of command.
Expand Down Expand Up @@ -69,5 +70,4 @@ public function getOptions()
['force', 'f', InputOption::VALUE_NONE, 'Force the creation if file already exists.', null],
];
}

}
}
5 changes: 3 additions & 2 deletions src/Pingpong/Generators/Console/ScaffoldCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputOption;

class ScaffoldCommand extends Command {
class ScaffoldCommand extends Command
{

/**
* The name of command.
Expand Down Expand Up @@ -59,4 +60,4 @@ public function getOptions()
['force', 'f', InputOption::VALUE_NONE, 'Force the creation if file already exists.', null],
];
}
}
}
3 changes: 2 additions & 1 deletion src/Pingpong/Generators/Console/SeedCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputOption;

class SeedCommand extends Command {
class SeedCommand extends Command
{

/**
* The name of command.
Expand Down
5 changes: 3 additions & 2 deletions src/Pingpong/Generators/Console/ViewCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputOption;

class ViewCommand extends Command {
class ViewCommand extends Command
{

/**
* The name of command.
Expand Down Expand Up @@ -73,4 +74,4 @@ public function getOptions()
['force', 'f', InputOption::VALUE_NONE, 'Force the creation if file already exists.', null],
];
}
}
}
6 changes: 3 additions & 3 deletions src/Pingpong/Generators/ConsoleGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

namespace Pingpong\Generators;

class ConsoleGenerator extends Generator {
class ConsoleGenerator extends Generator
{

/**
* Get stub name.
Expand Down Expand Up @@ -43,5 +44,4 @@ public function getReplacements()
'description' => $this->option('description', 'Command description'),
]);
}

}
}
16 changes: 6 additions & 10 deletions src/Pingpong/Generators/ControllerGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

use Pingpong\Generators\Scaffolders\ControllerScaffolder;

class ControllerGenerator extends Generator {
class ControllerGenerator extends Generator
{

/**
* Get stub name.
Expand All @@ -20,12 +21,9 @@ class ControllerGenerator extends Generator {
*/
public function setUp()
{
if ($this->resource)
{
if ($this->resource) {
$this->stub = 'controller/resource';
}
elseif ($this->scaffold)
{
} elseif ($this->scaffold) {
$this->stub = 'controller/scaffold';
$this->scaffolder = new ControllerScaffolder($this->getClass(), $this->getPrefix());
}
Expand Down Expand Up @@ -74,12 +72,10 @@ public function getReplacements()
{
$replacements = array_merge(parent::getReplacements(), ['root_namespace' => $this->getAppNamespace()]);

if ($this->scaffold)
{
if ($this->scaffold) {
return array_merge($replacements, $this->scaffolder->toArray());
}

return $replacements;
}

}
}
6 changes: 3 additions & 3 deletions src/Pingpong/Generators/FileAlreadyExistsException.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

use Exception;

class FileAlreadyExistsException extends Exception {

}
class FileAlreadyExistsException extends Exception
{
}
40 changes: 21 additions & 19 deletions src/Pingpong/Generators/FormDumpers/FieldsDumper.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
use Pingpong\Generators\Migrations\SchemaParser;
use Pingpong\Generators\Stub;

class FieldsDumper {
class FieldsDumper
{

use StubTrait;

Expand Down Expand Up @@ -45,8 +46,7 @@ public function render()
{
$results = '';

foreach ($this->getParser()->toArray() as $name => $types)
{
foreach ($this->getParser()->toArray() as $name => $types) {
$results .= $this->getStub($this->getFieldType($types), $name) . PHP_EOL;
}

Expand All @@ -55,16 +55,17 @@ public function render()

/**
* Convert the fields to html heading.
*
*
* @return string
*/
public function toHeading()
{
$results = '';

foreach ($this->getParser()->toArray() as $name => $types)
{
if (in_array($name, $this->ignores)) continue;
foreach ($this->getParser()->toArray() as $name => $types) {
if (in_array($name, $this->ignores)) {
continue;
}

$results .= "\t\t\t".'<th>' . ucwords($name) . '</th>'.PHP_EOL;
}
Expand All @@ -82,38 +83,39 @@ public function toBody($var)
{
$results = '';

foreach ($this->getParser()->toArray() as $name => $types)
{
if (in_array($name, $this->ignores)) continue;
foreach ($this->getParser()->toArray() as $name => $types) {
if (in_array($name, $this->ignores)) {
continue;
}

$results .= "\t\t\t\t\t".'<td>{!! $'.$var.'->' . $name . ' !!}</td>'.PHP_EOL;
$results .= "\t\t\t\t\t".'<td>{!! $'.$var.'->' . $name . ' !!}</td>'.PHP_EOL;
}

return $results;
return $results;
}

/**
* Get replacements for $SHOW_BODY$.
*
*
* @param string $var
* @return string
*/
public function toRows($var)
{
$results = PHP_EOL;

foreach ($this->getParser()->toArray() as $name => $types)
{
if (in_array($name, $this->ignores)) continue;
foreach ($this->getParser()->toArray() as $name => $types) {
if (in_array($name, $this->ignores)) {
continue;
}

$results .= Stub::create(__DIR__ . '/../Stubs/scaffold/row.stub', [
'label' => ucwords($name),
'column' => $name,
'var' => $var
])->render();
])->render();
}

return $results . PHP_EOL;
}

}
}
18 changes: 8 additions & 10 deletions src/Pingpong/Generators/FormDumpers/StubTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

use Pingpong\Generators\Stub;

trait StubTrait {
trait StubTrait
{

/**
* The array of types.
Expand Down Expand Up @@ -63,8 +64,9 @@ trait StubTrait {
*/
public function getStub($type, $name)
{
if (in_array($name, $this->ignores))
if (in_array($name, $this->ignores)) {
return null;
}

$type = $this->getInputType($type, $name);

Expand All @@ -83,13 +85,11 @@ public function getStub($type, $name)
*/
public function getInputType($type, $name)
{
if (in_array($name, $this->specials))
{
if (in_array($name, $this->specials)) {
return $name;
}

if (array_key_exists($type, $this->types))
{
if (array_key_exists($type, $this->types)) {
return $this->types[$type];
}

Expand All @@ -104,10 +104,8 @@ public function getInputType($type, $name)
*/
public function getFieldType($types)
{
return array_first($types, function ($key, $value)
{
return array_first($types, function ($key, $value) {
return $value;
});
}

}
}
Loading

0 comments on commit 869bc9c

Please sign in to comment.