Skip to content

Commit

Permalink
Factory code with coding standards
Browse files Browse the repository at this point in the history
  • Loading branch information
JackieDo committed May 16, 2017
1 parent b41af1a commit e7bdd08
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 47 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/vendor
composer.phar
composer.lock
.php_cs.cache
.DS_Store
12 changes: 7 additions & 5 deletions src/Jackiedo/Timezonelist/Timezonelist.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,9 @@ class Timezonelist
*
* @return string
*/
protected function formatTimezone($timezone, $continent) {
$time = new DateTime(NULL, new DateTimeZone($timezone));
protected function formatTimezone($timezone, $continent)
{
$time = new DateTime(null, new DateTimeZone($timezone));
$offset = $time->format('P');
$offset = str_replace('-', ' − ', $offset);
$offset = str_replace('+', ' + ', $offset);
Expand All @@ -74,7 +75,8 @@ protected function formatTimezone($timezone, $continent) {
* @param mixed $attr
* @return string
**/
public function create($name, $selected='', $attr='') {
public function create($name, $selected='', $attr='')
{

// Attributes for select element
$attrSet = null;
Expand Down Expand Up @@ -130,8 +132,8 @@ public function create($name, $selected='', $attr='') {
*
* @return mixed
**/
public function toArray() {

public function toArray()
{
$list = [];

// Add popular timezones to list
Expand Down
84 changes: 42 additions & 42 deletions src/Jackiedo/Timezonelist/TimezonelistServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,50 +9,50 @@
* @package Jackiedo\Timezonelist
* @author Jackie Do <[email protected]>
*/
class TimezonelistServiceProvider extends ServiceProvider {

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

/**
* Bootstrap the application events.
*
* @return void
*/
public function boot()
{
//
}

/**
* Register the service provider.
*
* @return void
*/
public function register()
{
$this->app->singleton('timezonelist', function($app) {
return new Timezonelist;
});
class TimezonelistServiceProvider extends ServiceProvider
{

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

/**
* Bootstrap the application events.
*
* @return void
*/
public function boot()
{
//
}

/**
* Register the service provider.
*
* @return void
*/
public function register()
{
$this->app->singleton('timezonelist', function ($app) {
return new Timezonelist;
});

$this->app->booting(function() {
$this->app->booting(function () {
$loader = AliasLoader::getInstance();
$loader->alias('Timezonelist', 'Jackiedo\Timezonelist\Facades\Timezonelist');
});
}

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

}

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

0 comments on commit e7bdd08

Please sign in to comment.