Skip to content

Commit

Permalink
Develop (#66)
Browse files Browse the repository at this point in the history
* Fix model path in the repository generator

* Fix #61: Convert $id to $primaryKey

* Fix #61: Convert $id to $primaryKey
* Implement pho_cs and perform nitpick"
  • Loading branch information
Tjoosten authored Nov 26, 2017
1 parent 7122584 commit db37d21
Show file tree
Hide file tree
Showing 28 changed files with 252 additions and 149 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/vendor
composer.phar
composer.lock
/.idea
/.idea
/.php_cs.cache
19 changes: 19 additions & 0 deletions .php_cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php
$finder = Symfony\Component\Finder\Finder::create()
->notPath('bootstrap')
->notPath('storage')
->notPath('vendor')
->in(__DIR__)
->name('*.php')
->name('_ide_helper')
->notName('*.blade.php')
->ignoreDotFiles(true)
->ignoreVCS(true);
return PhpCsFixer\Config::create()
->setRules([
'@PSR2' => true,
'array_syntax' => ['syntax' => 'short'],
'ordered_imports' => ['sortAlgorithm' => 'alpha'],
'no_unused_imports' => true,
])
->setFinder($finder);
1 change: 0 additions & 1 deletion .php_cs.cache
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
{"php":"7.1.11","version":"2.8.2:v2.8.2#b331701944cbe492e466d2b46b2880068803eb08","rules":{"blank_line_after_namespace":true,"braces":true,"class_definition":true,"elseif":true,"function_declaration":true,"indentation_type":true,"line_ending":true,"lowercase_constants":true,"lowercase_keywords":true,"method_argument_space":{"ensure_fully_multiline":true},"no_break_comment":true,"no_closing_tag":true,"no_spaces_after_function_name":true,"no_spaces_inside_parenthesis":true,"no_trailing_whitespace":true,"no_trailing_whitespace_in_comment":true,"single_blank_line_at_eof":true,"single_class_element_per_statement":{"elements":["property"]},"single_import_per_statement":true,"single_line_after_imports":true,"switch_case_semicolon_to_colon":true,"switch_case_space":true,"visibility_required":true,"encoding":true,"full_opening_tag":true},"hashes":[]}
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
"illuminate/support": "5.4.*|5.5.*",
"illuminate/database": "5.4.*|5.5.*",
"illuminate/filesystem": "5.4.*|5.5.*",
"illuminate/console": "5.4.*|5.5.*"
"illuminate/console": "5.4.*|5.5.*",
"friendsofphp/php-cs-fixer": "^2.8"
},
"require-dev": {
"mockery/mockery": "dev-master@dev",
"squizlabs/php_codesniffer": "3.*",
"phpunit/phpunit": "~5.7|~6.0",
"orchestra/testbench": "~3.0"
},
Expand Down
8 changes: 4 additions & 4 deletions config/repositories.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@

/**
* --------------------------------------------------------------------------
* Repository namespace
* Repository namespace
* --------------------------------------------------------------------------
*
*
* The namespace for the repository classes.
*
*
*/
'repository_namespace' => 'App\Repositories',

Expand Down Expand Up @@ -150,4 +150,4 @@
'except' => null,
],
],
];
];
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@

namespace ActivismeBE\DatabaseLayering\Repositories\Console\Commands\Creators;

use Doctrine\Common\Inflector\Inflector;
use Illuminate\Filesystem\Filesystem;
use Illuminate\Support\Facades\Config;
use Doctrine\Common\Inflector\Inflector;

/**
* Class CriteriaCreator
*
* @package ActivismeBE\DatabaseLayering\Console\Commands\Creators
*/
class CriteriaCreator
class CriteriaCreator
{
protected $files; /** @var Filesystem */
protected $criteria; /** @var Criteria */
Expand Down Expand Up @@ -147,7 +147,7 @@ protected function getPath()
*/
protected function getStub()
{
return $this->files->get($this->getStubPath() . "criteria.stub"); // Return the stub.
return $this->files->get($this->getStubPath() . "criteria.stub"); // Return the stub.
}

/**
Expand All @@ -157,7 +157,7 @@ protected function getStub()
*/
protected function getStubPath()
{
// TODO: Check if we can refactor this one.
// TODO: Check if we can refactor this one.

$path = __DIR__ . '/../../../../../../resources/stubs/'; // Path
return $path; // Return the path.
Expand Down Expand Up @@ -204,4 +204,4 @@ protected function pluralizeModel()

return $model_name; // Return the pluralized model.
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@

namespace ActivismeBE\DatabaseLayering\Repositories\Console\Commands\Creators;

use Doctrine\Common\Inflector\Inflector;
use Illuminate\Filesystem\Filesystem;
use Illuminate\Support\Facades\Config;
use Doctrine\Common\Inflector\Inflector;

/**
* Class RepositoryCreator
*
* @package ActivismeBE\DatabaseLayering\Console\Commands\Creators
*/
class RepositoryCreator
class RepositoryCreator
{
protected $files; /** @var FileSystem */
protected $repository; /** @var Repository */
Expand Down Expand Up @@ -74,8 +74,8 @@ public function create($repository, $model)
}

/**
* Create a new directory if the directory doesn't exists.
*
* Create a new directory if the directory doesn't exists.
*
* @return void
*/
protected function createDirectory()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

namespace ActivismeBE\DatabaseLayering\Repositories\Console\Commands;

use ActivismeBE\DatabaseLayering\Repositories\Console\Commands\Creators\CriteriaCreator;
use Illuminate\Console\Command;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputArgument;
use ActivismeBE\DatabaseLayering\Repositories\Console\Commands\Creators\CriteriaCreator;
use Symfony\Component\Console\Input\InputOption;

/**
* Class MakeCriteriaCommand
Expand Down Expand Up @@ -74,7 +74,7 @@ public function writeCriteria($arguments, $options)
$criteria = $arguments['criteria']; // Set criteria
$model = $options['model']; // Set model.

if ($this->creator->create($criteria, $model)) { // Create the criteria.
if ($this->creator->create($criteria, $model)) { // Create the criteria.
$this->info("Succesfully created the criteria class."); // Information message.
}
}
Expand All @@ -98,4 +98,4 @@ protected function getOptions()
{
return [['model', null, InputOption::VALUE_OPTIONAL, 'The model name.', null]];
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,51 +2,51 @@

namespace ActivismeBE\DatabaseLayering\Repositories\Console\Commands;

use Illuminate\Console\Command;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputArgument;
use ActivismeBE\DatabaseLayering\Repositories\Console\Commands\Creators\RepositoryCreator;
use Illuminate\Console\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputOption;

/**
* Class MakeRepositoryCommand
*
*
* @package ActivismeBE\DatabaseLayering\Repositories\Console\Commands
*/
class MakeRepositoryCommand extends Command
class MakeRepositoryCommand extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $name = 'make:repository';
* The name and signature of the console command.
*
* @var string
*/
protected $name = 'make:repository';

/**
* The console command description.
*
* @var string
* The console command description.
*
* @var string
*/
protected $description = 'Create a new repository class';

/**
* @var RepositoryCreator
*/
protected $creator;
protected $creator;

/**
* @var Composer
*/
protected $composer;
* @var Composer
*/
protected $composer;

/**
* @param RepositoryCreator $creator
* @param RepositoryCreator $creator
*/
public function __construct(RepositoryCreator $creator)
public function __construct(RepositoryCreator $creator)
{
parent::__construct();
parent::__construct();

$this->creator = $creator; // Set the creator
$this->composer = app()['composer']; // Set Composer
$this->composer = app()['composer']; // Set Composer
}

/**
Expand Down Expand Up @@ -77,11 +77,11 @@ protected function writeRepository($arguments, $options)
}
}

/**
* Get the console command arguments.
*
* @return array
*/
/**
* Get the console command arguments.
*
* @return array
*/
protected function getArguments()
{
return [['repository', InputArgument::REQUIRED, 'The repository name.']];
Expand All @@ -96,4 +96,4 @@ protected function getOptions()
{
return [['model', null, InputOption::VALUE_OPTIONAL, 'The model name.', null]];
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,4 @@ public function getCacheMinutes();
* @return $this
*/
public function skipCache($status = true);
}
}
8 changes: 4 additions & 4 deletions src/ActivismeBE/Repositories/Contracts/CriteriaInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@

/**
* Interface CriteriaInterface
*
*
* @package ActivismeBE\DatabaseLayering\Contracts
*/
interface CriteriaInterface
interface CriteriaInterface
{
/**
* @param bool $status
Expand All @@ -24,7 +24,7 @@ public function getCriteria();

/**
* @param Criteria $criteria
*
*
* @return $this
*/
public function getByCriteria(Criteria $criteria);
Expand All @@ -39,4 +39,4 @@ public function pushCriteria(Criteria $criteria);
* @return $this
*/
public function applyCriteria();
}
}
Loading

0 comments on commit db37d21

Please sign in to comment.