Skip to content
This repository has been archived by the owner on Nov 26, 2024. It is now read-only.

Commit

Permalink
Apply PHP CS Fixer
Browse files Browse the repository at this point in the history
  • Loading branch information
nasrulhazim committed Oct 2, 2018
1 parent 828df78 commit 1fb7fb4
Show file tree
Hide file tree
Showing 16 changed files with 202 additions and 203 deletions.
1 change: 1 addition & 0 deletions .php_cs.cache
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"php":"7.2.10","version":"2.13.0","rules":{"binary_operator_spaces":{"default":"align_single_space_minimal"},"blank_line_after_opening_tag":true,"blank_line_before_statement":{"statements":["return"]},"braces":{"allow_single_line_closure":true},"cast_spaces":true,"class_attributes_separation":{"elements":["method"]},"class_definition":{"multiLineExtendsEachSingleLine":true},"concat_space":{"spacing":"one"},"declare_equal_normalize":true,"function_typehint_space":true,"include":true,"increment_style":true,"lowercase_cast":true,"lowercase_static_reference":true,"magic_constant_casing":true,"magic_method_casing":true,"method_argument_space":true,"native_function_casing":true,"new_with_braces":true,"no_blank_lines_after_class_opening":true,"no_blank_lines_after_phpdoc":true,"no_empty_comment":true,"no_empty_phpdoc":true,"no_empty_statement":true,"no_extra_blank_lines":{"tokens":["curly_brace_block","extra","parenthesis_brace_block","square_brace_block","throw","use"]},"no_leading_import_slash":true,"no_leading_namespace_whitespace":true,"no_mixed_echo_print":{"use":"echo"},"no_multiline_whitespace_around_double_arrow":true,"no_short_bool_cast":true,"no_singleline_whitespace_before_semicolons":true,"no_spaces_around_offset":true,"no_trailing_comma_in_list_call":true,"no_trailing_comma_in_singleline_array":true,"no_unneeded_control_parentheses":true,"no_unneeded_curly_braces":true,"no_unneeded_final_method":true,"no_unused_imports":true,"no_whitespace_before_comma_in_array":true,"no_whitespace_in_blank_line":true,"normalize_index_brace":true,"object_operator_without_whitespace":true,"php_unit_fqcn_annotation":true,"phpdoc_align":{"tags":["method","param","property","return","throws","type","var"]},"phpdoc_annotation_without_dot":true,"phpdoc_indent":true,"phpdoc_inline_tag":true,"phpdoc_no_access":true,"phpdoc_no_alias_tag":true,"phpdoc_no_empty_return":true,"phpdoc_no_package":true,"phpdoc_no_useless_inheritdoc":true,"phpdoc_return_self_reference":true,"phpdoc_scalar":true,"phpdoc_separation":true,"phpdoc_single_line_var_spacing":true,"phpdoc_summary":true,"phpdoc_to_comment":true,"phpdoc_trim":true,"phpdoc_types":true,"phpdoc_var_without_name":true,"protected_to_private":true,"return_type_declaration":true,"semicolon_after_instruction":true,"short_scalar_cast":true,"single_blank_line_before_namespace":true,"single_class_element_per_statement":true,"single_line_comment_style":{"comment_types":["hash"]},"single_quote":true,"space_after_semicolon":{"remove_in_empty_for_expressions":true},"standardize_increment":true,"standardize_not_equals":true,"ternary_operator_spaces":true,"trailing_comma_in_multiline_array":true,"trim_array_spaces":true,"unary_operator_spaces":true,"whitespace_after_comma_in_array":true,"yoda_style":true,"blank_line_after_namespace":true,"elseif":true,"function_declaration":true,"indentation_type":true,"line_ending":true,"lowercase_constants":true,"lowercase_keywords":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_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,"ordered_class_elements":["use_trait","constant_public","constant_protected","constant_private","property_public","property_protected","property_private","construct","destruct","magic","phpunit","method_public","method_protected","method_private"],"array_syntax":{"syntax":"short"},"linebreak_after_opening_tag":true,"not_operator_with_successor_space":true,"ordered_imports":true,"phpdoc_order":true},"hashes":{"config\/attendance.php":1968799351,"database\/seeds\/AttendanceTypeSeeder.php":965999979,"src\/Adapters\/ApiAdapter.php":712951294,"src\/Adapters\/BaseAdapter.php":983632699,"src\/Adapters\/ConsoleAdapter.php":3911315451,"src\/Adapters\/WebAdapter.php":3695591437,"src\/AttendanceFacade.php":2887602336,"src\/AttendanceServiceProvider.php":895493519,"src\/Console\/Commands\/InstallCommand.php":2496148456,"src\/Console\/Commands\/LogAttendanceCommand.php":4050377130,"src\/Console\/Commands\/MakeAttendanceAdapterCommand.php":2604631063,"src\/Console\/Commands\/SeedAttendanceTypesCommand.php":1117661199,"src\/Http\/Controllers\/Api\/AttendanceController.php":1223798463,"src\/Http\/Controllers\/Controller.php":1080215761,"src\/Models\/Attendance.php":4048419665,"src\/Models\/AttendanceType.php":566522005,"src\/Support\/helpers.php":52093902,"tests\/PackageTest.php":1161420402,"tests\/TestCase.php":235502886,"tests\/Traits\/UserTrait.php":3051346990}}
26 changes: 13 additions & 13 deletions config/attendance.php
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
<?php
<?php

return [
'timezone' => env('ATTENDANCE_TIMEZONE', 'Asia/Kuala_Lumpur'),
'models' => [
'user' => \App\User::class,
'attendance' => \CleaniqueCoders\Attendance\Models\Attendance::class,
'type' => \CleaniqueCoders\Attendance\Models\AttendanceType::class,
],
'drivers' => [
'web' => \CleaniqueCoders\Attendance\Adapters\WebAdapter::class,
'api' => \CleaniqueCoders\Attendance\Adapters\ApiAdapter::class,
'console' => \CleaniqueCoders\Attendance\Adapters\ConsoleAdapter::class,
],
];
'timezone' => env('ATTENDANCE_TIMEZONE', 'Asia/Kuala_Lumpur'),
'models' => [
'user' => \App\User::class,
'attendance' => \CleaniqueCoders\Attendance\Models\Attendance::class,
'type' => \CleaniqueCoders\Attendance\Models\AttendanceType::class,
],
'drivers' => [
'web' => \CleaniqueCoders\Attendance\Adapters\WebAdapter::class,
'api' => \CleaniqueCoders\Attendance\Adapters\ApiAdapter::class,
'console' => \CleaniqueCoders\Attendance\Adapters\ConsoleAdapter::class,
],
];
14 changes: 6 additions & 8 deletions database/seeds/AttendanceTypeSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,19 @@ class AttendanceTypeSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
$data = [
'Time In',
'Time Out',
'Time In',
'Time Out',
];

foreach ($data as $datum) {
\CleaniqueCoders\Attendance\Models\AttendanceType::create([
'name' => $datum,
'label' => kebab_case($datum),
]);
\CleaniqueCoders\Attendance\Models\AttendanceType::create([
'name' => $datum,
'label' => kebab_case($datum),
]);
}
}
}
22 changes: 11 additions & 11 deletions src/Adapters/ApiAdapter.php
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
<?php
<?php

namespace CleaniqueCoders\Attendance\Adapters;

class ApiAdapter extends BaseAdapter
{
protected $driver = 'api';
protected $driver = 'api';

public function timeIn()
{
$this->capture(AttendanceType::TIME_IN);
}
public function timeIn()
{
$this->capture(AttendanceType::TIME_IN);
}

public function timeOut()
{
$this->capture(AttendanceType::TIME_OUT);
}
}
public function timeOut()
{
$this->capture(AttendanceType::TIME_OUT);
}
}
78 changes: 39 additions & 39 deletions src/Adapters/BaseAdapter.php
Original file line number Diff line number Diff line change
@@ -1,46 +1,46 @@
<?php
<?php

namespace CleaniqueCoders\Attendance\Adapters;

use App\Models\AttendanceType;
use Illuminate\Support\Carbon;
use Illuminate\Foundation\Auth\User;
use Illuminate\Support\Carbon;

abstract class BaseAdapter
{
abstract public function timeIn();
abstract public function timeOut();

public function __construct(User $user, Carbon $time)
{
$this->user = $user;
$this->time = $time;
}

public function driver()
{
return $this->driver;
}

public function user()
{
return $this->user;
}

public function time()
{
return $this->time;
}

public function capture(int $type, string $identifier = null, $data = null)
{
config('attendance.models.attendance')::create([
'user_id' => $this->user()->id,
'identifier' => $identifier,
'data' => $data,
'attendance_type_id' => $type,
'driver' => $this->driver(),
'created_at' => $this->time(),
]);
}
}
public function __construct(User $user, Carbon $time)
{
$this->user = $user;
$this->time = $time;
}

abstract public function timeIn();

abstract public function timeOut();

public function driver()
{
return $this->driver;
}

public function user()
{
return $this->user;
}

public function time()
{
return $this->time;
}

public function capture(int $type, string $identifier = null, $data = null)
{
config('attendance.models.attendance')::create([
'user_id' => $this->user()->id,
'identifier' => $identifier,
'data' => $data,
'attendance_type_id' => $type,
'driver' => $this->driver(),
'created_at' => $this->time(),
]);
}
}
22 changes: 11 additions & 11 deletions src/Adapters/ConsoleAdapter.php
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
<?php
<?php

namespace CleaniqueCoders\Attendance\Adapters;

class ConsoleAdapter extends BaseAdapter
{
protected $driver = 'console';
protected $driver = 'console';

public function timeIn()
{
$this->capture(AttendanceType::TIME_IN);
}
public function timeIn()
{
$this->capture(AttendanceType::TIME_IN);
}

public function timeOut()
{
$this->capture(AttendanceType::TIME_OUT);
}
}
public function timeOut()
{
$this->capture(AttendanceType::TIME_OUT);
}
}
22 changes: 11 additions & 11 deletions src/Adapters/WebAdapter.php
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
<?php
<?php

namespace CleaniqueCoders\Attendance\Adapters;

class WebAdapter extends BaseAdapter
{
protected $driver = 'web';
protected $driver = 'web';

public function timeIn()
{
$this->capture(AttendanceType::TIME_IN);
}
public function timeIn()
{
$this->capture(AttendanceType::TIME_IN);
}

public function timeOut()
{
$this->capture(AttendanceType::TIME_OUT);
}
}
public function timeOut()
{
$this->capture(AttendanceType::TIME_OUT);
}
}
2 changes: 1 addition & 1 deletion src/AttendanceServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function boot()
if (! class_exists('CreateAttendancesTable')) {
$this->publishes([
__DIR__ . '/../database/migrations/create_attendance_types_table.stub' => database_path('migrations/' . date('Y_m_d_His', time()) . '_create_attendance_types_table.php'),
__DIR__ . '/../database/migrations/create_attendances_table.stub' => database_path('migrations/' . date('Y_m_d_His', time()) . '_create_attendances_table.php'),
__DIR__ . '/../database/migrations/create_attendances_table.stub' => database_path('migrations/' . date('Y_m_d_His', time()) . '_create_attendances_table.php'),
], 'attendance-database');
}

Expand Down
6 changes: 2 additions & 4 deletions src/Console/Commands/LogAttendanceCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ class LogAttendanceCommand extends Command

/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
Expand All @@ -42,11 +40,11 @@ public function handle()
->firstOrFail();
$adapter = new \App\Adapters\ConsoleAdapter($user, now());

if($this->argument('type') == \App\Models\AttendanceType::TIME_IN) {
if (\App\Models\AttendanceType::TIME_IN == $this->argument('type')) {
$adapter->timeIn();
}

if($this->argument('type') == \App\Models\AttendanceType::TIME_OUT) {
if (\App\Models\AttendanceType::TIME_OUT == $this->argument('type')) {
$adapter->timeOut();
}

Expand Down
48 changes: 25 additions & 23 deletions src/Console/Commands/MakeAttendanceAdapterCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace CleaniqueCoders\Attendance\Console\Commands;

use Illuminate\Support\Str;
use Illuminate\Console\GeneratorCommand;
use Symfony\Component\Console\Input\InputOption;

Expand All @@ -29,25 +28,42 @@ class MakeAttendanceAdapterCommand extends GeneratorCommand
*/
protected $type = 'Adapter';

/**
* Execute the console command.
*
* @return bool|null
*/
public function handle()
{
if (! $this->option('driver')) {
$this->error('Driver name not specified!');

return false;
}

parent::handle();
}

/**
* Get the stub file for the generator.
*
* @return string
*/
protected function getStub()
{
return __DIR__.'/stubs/attendance.stub';
return __DIR__ . '/stubs/attendance.stub';
}

/**
* Get the default namespace for the class.
*
* @param string $rootNamespace
* @param string $rootNamespace
*
* @return string
*/
protected function getDefaultNamespace($rootNamespace)
{
return $rootNamespace.'\Adapters';
return $rootNamespace . '\Adapters';
}

/**
Expand All @@ -65,30 +81,16 @@ protected function getOptions()
/**
* Replace the class name for the given stub.
*
* @param string $stub
* @param string $name
* @param string $stub
* @param string $name
*
* @return string
*/
protected function replaceClass($stub, $name)
{
$class = str_replace($this->getNamespace($name).'\\', '', $name);
$driver = $this->option('driver');
$class = str_replace($this->getNamespace($name) . '\\', '', $name);
$driver = $this->option('driver');

return str_replace(['DummyClass', 'DummyDriver'], [$class, $driver], $stub);
}

/**
* Execute the console command.
*
* @return bool|null
*/
public function handle()
{
if(!$this->option('driver')) {
$this->error('Driver name not specified!');
return false;
}

parent::handle();
}
}
8 changes: 5 additions & 3 deletions src/Http/Controllers/Api/AttendanceController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@

namespace CleaniqueCoders\Attendance\Http\Controllers\Api;

use Illuminate\Http\Request;
use CleaniqueCoders\Attendance\Http\Controllers\Controller;
use Illuminate\Http\Request;

class AttendanceController extends Controller
{
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param \Illuminate\Http\Request $request
*
* @return \Illuminate\Http\Response
*/
public function timeIn(Request $request)
Expand All @@ -27,7 +28,8 @@ public function timeIn(Request $request)
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param \Illuminate\Http\Request $request
*
* @return \Illuminate\Http\Response
*/
public function timeOut(Request $request)
Expand Down
Loading

0 comments on commit 1fb7fb4

Please sign in to comment.