Skip to content

Commit

Permalink
Run php-cs-fixer over the package
Browse files Browse the repository at this point in the history
This is simply the output of `php-cs-fixer fix --level=psr2` over the
`src` and `tests` folder as well as manually reformatting the
`composer.json` file and adding a missing newline to `LICENSE`.
  • Loading branch information
Andrew Smith committed Jun 29, 2015
1 parent ea2923a commit c0d1c52
Show file tree
Hide file tree
Showing 16 changed files with 305 additions and 277 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
SOFTWARE.
79 changes: 43 additions & 36 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,40 +1,47 @@
{
"name": "bosnadev/database",
"description": "Eloquent Extended, added some PostgreSql features",
"keywords": ["laravel", "eloquent", "database", "mysql", "postgresql", "database"],
"authors": [
{
"name": "Mirza Pasic",
"email": "mirza.pasic@edu.fit.ba"
},
{
"name": "Peter Haza",
"email": "peter.haza@gmail.com"
}
],
"require": {
"php": ">=5.4",
"illuminate/database": "~5.0",
"ramsey/uuid": "~2.8"
"name": "bosnadev/database",
"description": "Eloquent Extended, added some PostgreSql features",
"keywords": [
"laravel",
"eloquent",
"database",
"mysql",
"postgresql",
"database"
],
"authors": [
{
"name": "Mirza Pasic",
"email": "mirza.pasic@edu.fit.ba"
},
"require-dev": {
"php": ">=5.4",
"phpunit/phpunit": "~4.5",
"mockery/mockery": "0.9.*",
"doctrine/dbal": "~2.5"
{
"name": "Peter Haza",
"email": "peter.haza@gmail.com"
}
],
"require": {
"php": ">=5.4",
"illuminate/database": "~5.0",
"ramsey/uuid": "~2.8"
},
"require-dev": {
"php": ">=5.4",
"phpunit/phpunit": "~4.5",
"mockery/mockery": "0.9.*",
"doctrine/dbal": "~2.5"
},
"autoload": {
"psr-4": {
"Bosnadev\\Database\\": "src/"
},
"autoload": {
"psr-4": {
"Bosnadev\\Database\\": "src/"
},
"classmap": [
"tests/BaseTestCase.php"
]
},
"autoload-dev": {
"psr-4": {
"Bosnadev\\Tests\\Database\\": "tests/"
}
},
"minimum-stability": "stable"
"classmap": [
"tests/BaseTestCase.php"
]
},
"autoload-dev": {
"psr-4": {
"Bosnadev\\Tests\\Database\\": "tests/"
}
},
"minimum-stability": "stable"
}
14 changes: 6 additions & 8 deletions src/Connectors/ConnectionFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
* Class ConnectionFactory
* @package Bosnadev\Database\Connectors
*/
class ConnectionFactory extends \Illuminate\Database\Connectors\ConnectionFactory {

class ConnectionFactory extends \Illuminate\Database\Connectors\ConnectionFactory
{
/**
* @param string $driver
* @param PDO $connection
Expand All @@ -23,16 +23,14 @@ class ConnectionFactory extends \Illuminate\Database\Connectors\ConnectionFactor
*/
protected function createConnection($driver, PDO $connection, $database, $prefix = '', array $config = array())
{
if ($this->container->bound($key = "db.connection.{$driver}"))
{
if ($this->container->bound($key = "db.connection.{$driver}")) {
return $this->container->make($key, array($connection, $database, $prefix, $config));
}

if($driver === 'pgsql') {
if ($driver === 'pgsql') {
return new PostgresConnection($connection, $database, $prefix, $config);
}

return parent::createConnection( $driver, $connection, $database, $prefix, $config );
return parent::createConnection($driver, $connection, $database, $prefix, $config);
}

}
}
13 changes: 5 additions & 8 deletions src/DatabaseServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
* Class DatabaseServiceProvider
* @package Bosnadev\Database
*/
class DatabaseServiceProvider extends \Illuminate\Database\DatabaseServiceProvider {

class DatabaseServiceProvider extends \Illuminate\Database\DatabaseServiceProvider
{
/**
* Register the service provider.
*
Expand All @@ -19,18 +19,15 @@ public function register()
// The connection factory is used to create the actual connection instances on
// the database. We will inject the factory into the manager so that it may
// make the connections while they are actually needed and not of before.
$this->app->bindShared('db.factory', function($app)
{
$this->app->bindShared('db.factory', function ($app) {
return new ConnectionFactory($app);
});

// The database manager is used to resolve various connections, since multiple
// connections might be managed. It also implements the connection resolver
// interface which may be used by other components requiring connections.
$this->app->bindShared('db', function($app)
{
$this->app->bindShared('db', function ($app) {
return new DatabaseManager($app, $app['db.factory']);
});
}

}
}
12 changes: 6 additions & 6 deletions src/PostgresConnection.php
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
<?php namespace Bosnadev\Database;


use Illuminate\Database\PostgresConnection as BasePostgresConnection;

/**
* Class PostgresConnection
*
* @package Bosnadev\Database
*/
class PostgresConnection extends BasePostgresConnection {

class PostgresConnection extends BasePostgresConnection
{
/**
* Get a schema builder instance for the connection.
*
* @return Schema\Builder
*/
public function getSchemaBuilder()
{
if (is_null($this->schemaGrammar)) { $this->useDefaultSchemaGrammar(); }
if (is_null($this->schemaGrammar)) {
$this->useDefaultSchemaGrammar();
}

return new Schema\Builder($this);
}
Expand Down Expand Up @@ -53,5 +54,4 @@ protected function getDefaultPostProcessor()
{
return new \Illuminate\Database\Query\Processors\PostgresProcessor;
}

}
}
24 changes: 11 additions & 13 deletions src/Schema/Blueprint.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,19 @@
*/
class Blueprint extends \Illuminate\Database\Schema\Blueprint
{

/**
* Add the index commands fluently specified on columns.
*
* @return void
*/
protected function addFluentIndexes()
{
foreach ($this->columns as $column)
{
foreach (array('primary', 'unique', 'index', 'gin') as $index)
{
foreach ($this->columns as $column) {
foreach (array('primary', 'unique', 'index', 'gin') as $index) {
// If the index has been specified on the given column, but is simply
// equal to "true" (boolean), no name has been specified for this
// index, so we will simply call the index methods without one.
if ($column->$index === true)
{
if ($column->$index === true) {
$this->$index($column->name);

continue 2;
Expand All @@ -31,8 +27,7 @@ protected function addFluentIndexes()
// If the index has been specified on the column and it is something
// other than boolean true, we will assume a name was provided on
// the index specification, and pass in the name to the method.
elseif (isset($column->$index))
{
elseif (isset($column->$index)) {
$this->$index($column->name, $column->$index);

continue 2;
Expand Down Expand Up @@ -69,15 +64,17 @@ public function character($column, $length = 255)
* @param $column
* @return \Illuminate\Support\Fluent
*/
public function hstore($column) {
public function hstore($column)
{
return $this->addColumn('hstore', $column);
}

/**
* @param $column
* @return \Illuminate\Support\Fluent
*/
public function uuid($column) {
public function uuid($column)
{
return $this->addColumn('uuid', $column);
}

Expand All @@ -87,7 +84,8 @@ public function uuid($column) {
* @param $column
* @return \Illuminate\Support\Fluent
*/
public function jsonb($column) {
public function jsonb($column)
{
return $this->addColumn('jsonb', $column);
}
}
}
8 changes: 4 additions & 4 deletions src/Schema/Builder.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
<?php namespace Bosnadev\Database\Schema;

use Closure;

/**
* Class Builder
* @package Bosnadev\Database\Schema
*/
class Builder extends \Illuminate\Database\Schema\Builder {

class Builder extends \Illuminate\Database\Schema\Builder
{
/**
* Create a new command set with a Closure.
*
Expand All @@ -18,5 +19,4 @@ protected function createBlueprint($table, Closure $callback = null)
{
return new Blueprint($table, $callback);
}

}
}
32 changes: 20 additions & 12 deletions src/Schema/Grammars/PostgresGrammar.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@
* Class PostgresGrammar
* @package Bosnadev\Database\Schema\Grammars
*/
class PostgresGrammar extends \Illuminate\Database\Schema\Grammars\PostgresGrammar {


class PostgresGrammar extends \Illuminate\Database\Schema\Grammars\PostgresGrammar
{
/**
* Create the column definition for a character type.
*
Expand All @@ -27,7 +26,8 @@ protected function typeCharacter(Fluent $column)
* @param Fluent $column
* @return string
*/
protected function typeHstore(Fluent $column) {
protected function typeHstore(Fluent $column)
{
return "hstore";
}

Expand All @@ -37,7 +37,8 @@ protected function typeHstore(Fluent $column) {
* @param Fluent $column
* @return string
*/
protected function typeUuid(Fluent $column) {
protected function typeUuid(Fluent $column)
{
return "uuid";
}

Expand All @@ -47,7 +48,8 @@ protected function typeUuid(Fluent $column) {
* @param Fluent $column
* @return string
*/
protected function typeJsonb(Fluent $column) {
protected function typeJsonb(Fluent $column)
{
return "jsonb";
}

Expand All @@ -57,11 +59,17 @@ protected function typeJsonb(Fluent $column) {
*/
protected function getDefaultValue($value)
{
if ($value instanceof Expression) return $value;
if ($value instanceof Expression) {
return $value;
}

if (is_bool($value)) return "'".intval($value)."'";
if (is_bool($value)) {
return "'".intval($value)."'";
}

if( $this->isUuid( $value ) ) return strval($value);
if ($this->isUuid($value)) {
return strval($value);
}

return "'".strval($value)."'";
}
Expand All @@ -72,8 +80,9 @@ protected function getDefaultValue($value)
* @param $value
* @return int
*/
protected function isUuid($value) {
return preg_match( '/^uuid_generate_v/', $value );
protected function isUuid($value)
{
return preg_match('/^uuid_generate_v/', $value);
}

/**
Expand All @@ -89,5 +98,4 @@ public function compileGin(Blueprint $blueprint, Fluent $command)

return sprintf('CREATE INDEX %s ON %s USING GIN(%s)', $command->index, $this->wrapTable($blueprint), $columns);
}

}
Loading

0 comments on commit c0d1c52

Please sign in to comment.