Skip to content

Commit

Permalink
PHP Coding Standards Fixer PSR2
Browse files Browse the repository at this point in the history
  • Loading branch information
renatomarinho committed Nov 21, 2016
1 parent e6184bf commit 722e173
Show file tree
Hide file tree
Showing 147 changed files with 1,929 additions and 2,640 deletions.
306 changes: 144 additions & 162 deletions app/Classes/Github.php

Large diffs are not rendered by default.

15 changes: 8 additions & 7 deletions app/Classes/Helper.php
@@ -1,13 +1,15 @@
<?php namespace GitScrum\Classes;
<?php

class Helper {
namespace GitScrum\Classes;

public function arrayDateRange($between, $value=0)
class Helper
{
public function arrayDateRange($between, $value = 0)
{
$arr = [];

for ( $i = strtotime($between[0]); $i <= strtotime($between[1]); $i=$i+86400 ) {
$date=date('Y-m-d', $i);
for ($i = strtotime($between[0]); $i <= strtotime($between[1]); $i = $i + 86400) {
$date = date('Y-m-d', $i);
$arr[$date] = $value;
}

Expand All @@ -16,7 +18,6 @@ public function arrayDateRange($between, $value=0)

public static function slug($value)
{
return str_slug(substr($value,0,40) . '-' . uniqid());
return str_slug(substr($value, 0, 40).'-'.uniqid());
}

}
37 changes: 19 additions & 18 deletions app/Classes/Phpcs.php
@@ -1,18 +1,19 @@
<?php namespace GitScrum\Classes;
<?php

namespace GitScrum\Classes;

use Storage;
use GitScrum\CommitFile;
use GitScrum\CommitFilePhpcs;

class Phpcs
{

private $id;

public function init($fileContents, $commitFileId)
{
$this->id = $commitFileId;
$filename = uniqid(strtotime('now'),true);
$filename = uniqid(strtotime('now'), true);
Storage::disk('local_tmp')->put($filename.'.php', $fileContents);
$result = shell_exec('phpcs --report=diff '.storage_path('tmp').'/'.$filename.'.php 2>&1; echo $?');
$this->addSuggestionFix($result);
Expand All @@ -23,53 +24,53 @@ public function init($fileContents, $commitFileId)

private function addSuggestionFix($result)
{
$arr = explode('<br />',nl2br($result));
$arr = explode('<br />', nl2br($result));
$data = [];
$rows = array_slice($arr,2,(count($arr)-5));
$row = str_replace('<br />', '',implode('<br />',$rows));
$commit = CommitFile::where('id','=', $this->id)->first();
$rows = array_slice($arr, 2, (count($arr) - 5));
$row = str_replace('<br />', '', implode('<br />', $rows));
$commit = CommitFile::where('id', '=', $this->id)->first();
$commit->phpcs = $row;
$commit->save();
}

private function addPhpcs($data)
{
$commitReturn = $commit = CommitFilePhpcs::where('commit_file_id','=', $data['commit_file_id'])
$commitReturn = $commit = CommitFilePhpcs::where('commit_file_id', '=', $data['commit_file_id'])
->where('line', '=', $data['line'])
->first();
if($commit === null){
if ($commit === null) {
return $commit = CommitFilePhpcs::create($data);
} else {
$commit->update($data);

return $commitReturn;
}
}

private function convertToLines($result)
{
$arr = explode('<br />',nl2br($result));
$arr = explode('<br />', nl2br($result));
$data = [];
$row = '';
foreach ($arr as $value) {
$cols = explode('|', $value);
foreach ($cols as $col) {
$row .= trim(str_replace(['[ ]','[x]'],'',$col)) . '|';
$row .= trim(str_replace(['[ ]', '[x]'], '', $col)).'|';
}
}
$rows = explode('|', str_replace('|||',' ', $row));
$rows = array_slice($rows,5,(count($rows)-14));
$rows = explode('|', str_replace('|||', ' ', $row));
$rows = array_slice($rows, 5, (count($rows) - 14));
$i = 0;
$columns = ['line','type','message'];
foreach ($rows as $row){
$columns = ['line', 'type', 'message'];
foreach ($rows as $row) {
$data[$columns[$i]] = $row;
if($i==2){
if ($i == 2) {
$data['commit_file_id'] = $this->id;
$this->addPhpcs($data);
$i = 0;
} else {
$i++;
++$i;
}
}
}

}
9 changes: 2 additions & 7 deletions app/Classes/Phploc.php
@@ -1,12 +1,7 @@
<?php namespace GitScrum\Classes;
<?php

use Storage;
use GitScrum\CommitFile;
use GitScrum\CommitFilePhpcs;
namespace GitScrum\Classes;

class Phploc
{



}
16 changes: 7 additions & 9 deletions app/Classes/UserClass.php
@@ -1,21 +1,19 @@
<?php namespace GitScrum\Classes;
<?php

use Auth;
use GitScrum\Models\User;
namespace GitScrum\Classes;

class UserClass {
use GitScrum\Models\User;

class UserClass
{
public function save($data)
{
$userReturn = $user = User::where('github_id', '=', $data['github_id'])->first();

$userReturn= $user = User::where('github_id','=', $data['github_id'])->first();

if($user === null){
if ($user === null) {
return User::create($data);
} else {
return $userReturn;
}

}

}
7 changes: 2 additions & 5 deletions app/Console/Kernel.php
Expand Up @@ -13,14 +13,13 @@ class Kernel extends ConsoleKernel
* @var array
*/
protected $commands = [
//

];

/**
* Define the application's command schedule.
*
* @param \Illuminate\Console\Scheduling\Schedule $schedule
* @return void
* @param \Illuminate\Console\Scheduling\Schedule $schedule
*/
protected function schedule(Schedule $schedule)
{
Expand All @@ -30,8 +29,6 @@ protected function schedule(Schedule $schedule)

/**
* Register the Closure based commands for the application.
*
* @return void
*/
protected function commands()
{
Expand Down
13 changes: 7 additions & 6 deletions app/Exceptions/Handler.php
Expand Up @@ -27,8 +27,7 @@ class Handler extends ExceptionHandler
*
* This is a great spot to send exceptions to Sentry, Bugsnag, etc.
*
* @param \Exception $exception
* @return void
* @param \Exception $exception
*/
public function report(Exception $exception)
{
Expand All @@ -38,8 +37,9 @@ public function report(Exception $exception)
/**
* Render an exception into an HTTP response.
*
* @param \Illuminate\Http\Request $request
* @param \Exception $exception
* @param \Illuminate\Http\Request $request
* @param \Exception $exception
*
* @return \Illuminate\Http\Response
*/
public function render($request, Exception $exception)
Expand All @@ -50,8 +50,9 @@ public function render($request, Exception $exception)
/**
* Convert an authentication exception into an unauthenticated response.
*
* @param \Illuminate\Http\Request $request
* @param \Illuminate\Auth\AuthenticationException $exception
* @param \Illuminate\Http\Request $request
* @param \Illuminate\Auth\AuthenticationException $exception
*
* @return \Illuminate\Http\Response
*/
protected function unauthenticated($request, AuthenticationException $exception)
Expand Down
12 changes: 3 additions & 9 deletions app/Http/Controllers/Auth/AuthController.php
@@ -1,12 +1,10 @@
<?php
/**
* GitScrum v0.1
* GitScrum v0.1.
*
* @package GitScrum
* @author Renato Marinho <renato.marinho@s2move.com>
* @license http://opensource.org/licenses/GPL-3.0 GPLv3
*/

namespace GitScrum\Http\Controllers\Auth;

use GitScrum\Http\Requests\AuthRequest;
Expand All @@ -19,7 +17,6 @@

class AuthController extends Controller
{

protected $redirectTo = '/home';

public function login()
Expand All @@ -29,17 +26,14 @@ public function login()

public function doLogin(AuthRequest $request)
{

}

public function register()
{

}

public function doRegister()
{

}

public function redirectToProvider()
Expand All @@ -63,9 +57,9 @@ public function handleProviderCallback()
'blog' => $user->user['blog'],
'email' => $user->email,
];
$UserClass = new UserClass;
$UserClass = new UserClass();
Auth::loginUsingId($UserClass->save($data)->id);
return redirect()->route('user.dashboard');

return redirect()->route('user.dashboard');
}
}
30 changes: 12 additions & 18 deletions app/Http/Controllers/BranchController.php
@@ -1,18 +1,14 @@
<?php
/**
* GitScrum v0.1
* GitScrum v0.1.
*
* @package GitScrum
* @author Renato Marinho <renato.marinho@s2move.com>
* @license http://opensource.org/licenses/GPL-3.0 GPLv3
*/

namespace GitScrum\Http\Controllers;

use Illuminate\Http\Request;

use GitScrum\Http\Requests;

class BranchController extends Controller
{
/**
Expand All @@ -22,7 +18,6 @@ class BranchController extends Controller
*/
public function index()
{
//
}

/**
Expand All @@ -32,62 +27,61 @@ public function index()
*/
public function create()
{
//
}

/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param \Illuminate\Http\Request $request
*
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
//
}

/**
* Display the specified resource.
*
* @param int $id
* @param int $id
*
* @return \Illuminate\Http\Response
*/
public function show($id)
{
//
}

/**
* Show the form for editing the specified resource.
*
* @param int $id
* @param int $id
*
* @return \Illuminate\Http\Response
*/
public function edit($id)
{
//
}

/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param int $id
* @param \Illuminate\Http\Request $request
* @param int $id
*
* @return \Illuminate\Http\Response
*/
public function update(Request $request, $id)
{
//
}

/**
* Remove the specified resource from storage.
*
* @param int $id
* @param int $id
*
* @return \Illuminate\Http\Response
*/
public function destroy($id)
{
//
}
}

0 comments on commit 722e173

Please sign in to comment.