Skip to content

Commit

Permalink
standardise code to PSR-2
Browse files Browse the repository at this point in the history
  • Loading branch information
Mulkave committed Jul 23, 2015
1 parent 4f5c5c3 commit aa73b0b
Show file tree
Hide file tree
Showing 5 changed files with 108 additions and 104 deletions.
34 changes: 17 additions & 17 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
backupStaticAttributes="false"
bootstrap="vendor/autoload.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
syntaxCheck="false"
>
<testsuites>
<testsuite name="Package Test Suite">
<directory suffix=".php">./tests/</directory>
</testsuite>
</testsuites>
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
backupStaticAttributes="false"
bootstrap="vendor/autoload.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
syntaxCheck="false"
>
<testsuites>
<testsuite name="Package Test Suite">
<directory suffix=".php">./tests/</directory>
</testsuite>
</testsuites>
</phpunit>
102 changes: 49 additions & 53 deletions src/Vinelab/Country/CountryServiceProvider.php
Original file line number Diff line number Diff line change
@@ -1,53 +1,49 @@
<?php namespace Vinelab\Country;

use Illuminate\Support\ServiceProvider;

class CountryServiceProvider extends ServiceProvider {

/**
* Indicates if loading of the provider is deferred.
*
* @var bool
*/
protected $defer = false;

/**
* Bootstrap the application events.
*
* @return void
*/
public function boot()
{
$this->package('vinelab/country');
}

/**
* Register the service provider.
*
* @return void
*/
public function register()
{
$this->app->bind('vinelab.country', function()
{
return new Guide($this->app['config']);
});

$this->app->booting(function() {

$loader = \Illuminate\Foundation\AliasLoader::getInstance();
$loader->alias('Country', 'Vinelab\Country\Facades\Guide');
});
}

/**
* Get the services provided by the provider.
*
* @return array
*/
public function provides()
{
return array();
}

}
<?php

namespace Vinelab\Country;

use Illuminate\Support\ServiceProvider;

class CountryServiceProvider extends ServiceProvider
{
/**
* Indicates if loading of the provider is deferred.
*
* @var bool
*/
protected $defer = false;

/**
* Bootstrap the application events.
*/
public function boot()
{
$this->package('vinelab/country');
}

/**
* Register the service provider.
*/
public function register()
{
$this->app->bind('vinelab.country', function () {
return new Guide($this->app['config']);
});

$this->app->booting(function () {

$loader = \Illuminate\Foundation\AliasLoader::getInstance();
$loader->alias('Country', 'Vinelab\Country\Facades\Guide');
});
}

/**
* Get the services provided by the provider.
*
* @return array
*/
public function provides()
{
return array();
}
}
26 changes: 15 additions & 11 deletions src/Vinelab/Country/Facades/Guide.php
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
<?php namespace Vinelab\Country\Facades;
<?php

use Illuminate\Support\Facades\Facade;

Class Guide extends Facade {
namespace Vinelab\Country\Facades;

/**
* Get the registered name of the component.
*
* @return string
*/
protected static function getFacadeAccessor() { return 'vinelab.country'; }
use Illuminate\Support\Facades\Facade;

}
class Guide extends Facade
{
/**
* Get the registered name of the component.
*
* @return string
*/
protected static function getFacadeAccessor()
{
return 'vinelab.country';
}
}
46 changes: 25 additions & 21 deletions src/Vinelab/Country/Guide.php
Original file line number Diff line number Diff line change
@@ -1,26 +1,30 @@
<?php namespace Vinelab\Country;
<?php

Class Guide {
namespace Vinelab\Country;

function __construct(\Illuminate\Config\Repository $config)
{
$this->config = $config;
}
class Guide
{
public function __construct(\Illuminate\Config\Repository $config)
{
$this->config = $config;
}

public function name($abbreviation)
{
$abbreviation = strtoupper($abbreviation);
return $this->config->get("country::countries.{$abbreviation}");
}
public function name($abbreviation)
{
$abbreviation = strtoupper($abbreviation);

public function abbreviation($name)
{
$countries = $this->config->get('country::countries');
return array_search(ucwords($name), $countries);
}
return $this->config->get("country::countries.{$abbreviation}");
}

public function all()
{
return $this->config->get('country::countries');
}
}
public function abbreviation($name)
{
$countries = $this->config->get('country::countries');

return array_search(ucwords($name), $countries);
}

public function all()
{
return $this->config->get('country::countries');
}
}
4 changes: 2 additions & 2 deletions src/config/countries.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

return array (
return array(
'AD' => 'Andorra',
'AE' => 'United Arab Emirates',
'AF' => 'Afghanistan',
Expand Down Expand Up @@ -265,4 +265,4 @@
'ZM' => 'Zambia',
'ZW' => 'Zimbabwe',
'ZZ' => 'Unknown or Invalid Region',
);
);

0 comments on commit aa73b0b

Please sign in to comment.