Skip to content

Commit

Permalink
Factory with coding standards
Browse files Browse the repository at this point in the history
  • Loading branch information
JackieDo committed May 16, 2017
1 parent ad81458 commit dd64bc2
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 54 deletions.
8 changes: 5 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/bootstrap/compiled.php
.env.*.php
.env.php
/vendor
composer.phar
composer.lock
.php_cs.cache
.DS_Store
11 changes: 6 additions & 5 deletions src/Jackiedo/Timezonelist/Facades/Timezonelist.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,16 @@
* @copyright 2015 Jackie Do
*/

class Timezonelist extends Facade {
class Timezonelist extends Facade
{

/**
* Get the registered name of the component.
*
* @return string
*/
protected static function getFacadeAccessor() { return 'timezonelist'; }

protected static function getFacadeAccessor()
{
return 'timezonelist';
}
}

?>
15 changes: 9 additions & 6 deletions src/Jackiedo/Timezonelist/Timezonelist.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
* @copyright 2015 Jackie Do
*/

class Timezonelist {
class Timezonelist
{
/**
* Whitespace seperate
*/
Expand Down Expand Up @@ -53,8 +54,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 @@ -75,7 +77,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 @@ -131,8 +134,8 @@ public function create($name, $selected='', $attr='') {
*
* @return mixed
**/
public function toArray() {

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

// Add popular timezones to list
Expand Down
80 changes: 40 additions & 40 deletions src/Jackiedo/Timezonelist/TimezonelistServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,50 +10,50 @@
* @copyright 2015 Jackie Do
*/

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()
{
$this->package('jackiedo/timezonelist');
}

/**
* Register the service provider.
*
* @return void
*/
public function register()
{
$this->app['timezonelist'] = $this->app->share(function($app) {
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()
{
$this->package('jackiedo/timezonelist');
}

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

$this->app->booting(function() {
$this->app->booting(function () {
$loader = \Illuminate\Foundation\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 dd64bc2

Please sign in to comment.