Permalink
Browse files

Bring back phpmd and php_codesniffer

Invoke phpmd from lint target in Makefile. Apply recommendations from
phpmd.
  • Loading branch information...
lovett committed Jan 23, 2018
1 parent 4cea433 commit a044169ad14ebb1af0db4b90927a859a5483d54c
@@ -3,3 +3,6 @@
fakeseed: dummy
php artisan migrate:fresh
php artisan db:seed --class=FakeSeeder
lint: dummy
phpmd app text phpmd.xml
@@ -24,6 +24,7 @@ class Kernel extends ConsoleKernel
*/
protected function schedule(Schedule $schedule)
{
$schedule->command(null);
// $schedule->command('inspire')
// ->hourly();
}
@@ -33,17 +33,18 @@ public static function clientMailingAddress($record)
private static function mailingAddress($record, $fields=[])
{
$address = array_reduce($fields, function ($acc, $field) use ($record) {
$prefix = '';
$key = $field;
if (is_array($field)) {
list($prefix, $key) = $field;
} else {
$prefix = '';
$key = $field;
}
$suffix = "\n";
if ($key === 'city') {
$suffix = ', ';
} elseif ($key === 'locality') {
}
if ($key === 'locality') {
$suffix = ' ';
}
@@ -63,11 +63,9 @@ public function index(Request $request)
/**
* Show the form for creating a new client.
*
* @param Request $request The incoming request
*
* @return Response
*/
public function create(Request $request)
public function create()
{
$client = new Client();
@@ -182,7 +180,7 @@ public function update(ClientRequest $request, $id)
{
$client = $request->user()->client($id);
$affectedRows = $client->update($request->all());
$client->update($request->all());
if ($client->active === 0) {
// An inactive client should not have active projects.
@@ -211,7 +209,7 @@ public function destroy(Request $request, $id)
$client = $request->user()->client($id);
$affectedRows = $client->delete();
$client->delete();
MessagingHelper::flashDeleted($client->name);
@@ -3,6 +3,7 @@
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
class DashboardController extends Controller
{
@@ -20,9 +21,9 @@ public function __construct()
/**
* Show the application dashboard.
*
* @return \Illuminate\Http\Response
* @return Response
*/
public function index(Request $request)
public function index()
{
return view('home');
}
@@ -77,10 +77,13 @@ public function suggestByProject(Request $request, $id = 0)
public function create(Request $request)
{
$clientId = $request->input('client', null);
if ($clientId) {
$client = $request->user()->client($clientId)->firstOrFail();
$projects = $request->user()->projectsForMenu($client->getKey());
} else {
$projects = $request->user()->projectsByClientForMenu($client->getKey());
}
if (is_null($clientId)) {
$client = null;
$projects = $request->user()->projectsForMenu();
}
@@ -208,7 +208,7 @@ public function update(ProjectRequest $request, $id)
{
$project = $request->user()->project($id);
$affectedRows = $project->update($request->all());
$project->update($request->all());
MessagingHelper::flashUpdated($project->name);
@@ -232,9 +232,7 @@ public function destroy(Request $request, $id)
{
$project = $request->user()->project($id);
$affectedRows = $project->delete();
$message = sprintf("%s has been deleted", $project->name);
$project->delete();
MessagingHelper::flashDeleted($project->name);
@@ -69,14 +69,14 @@ public function create(Request $request)
$clientId = $request->input('client', null);
if ($clientId) {
$client = $request->user()->client($clientId)->firstOrFail();
$projects = $request->user()->projectsForMenu($client->getKey());
} else {
$projects = $request->user()->projectsByClientForMenu($client->getKey());
}
if (is_null($clientId)) {
$client = null;
$projects = $request->user()->projectsForMenu();
}
$projects = $request->user()->projectsForMenu();
$projectId = $request->input('project', null);
if (array_key_exists($projectId, $projects) === false) {
@@ -127,8 +127,6 @@ public function store(TimeRequest $request)
$time->user()->associate($request->user());
$time->save();
$userMessage = $this->successMessage('time entry');
MessagingHelper::flashCreated('time entry');
return redirect()->route(
@@ -174,7 +172,7 @@ public function update(TimeRequest $request, $id)
{
$time = $request->user()->time()->findOrFail($id);
$affectedRows = $time->update($request->all());
$time->update($request->all());
MessagingHelper::flashUpdated('time entry');
@@ -193,7 +191,7 @@ public function update(TimeRequest $request, $id)
*/
public function destroy(Request $request, $id)
{
$affectedRows = $request->user()->time()->where('id', $id)->delete();
$request->user()->time()->where('id', $id)->delete();
MessagingHelper::flashDeleted('time entry');
@@ -141,7 +141,7 @@ public function scopeRecent($query, $limit=0)
*
* @return Relation
*/
public function scopeListingByUser($query, $userId=0)
public function scopeListingByUser($query)
{
$query->leftJoin(
'projects',
@@ -128,21 +128,30 @@ public function clientsForMenu()
}
/**
* Return a menu-friendly list of the user's projects.
* Return a menu-friendly list of the user's projects across all clients
*
* @return array
*/
public function projectsForMenu($clientId=0)
public function projectsForMenu()
{
if ($clientId > 0) {
$query = $this->client($clientId)->projects()->getQuery();
} else {
$query = $this->projects();
}
$query = $this->projects()->with('client')->orderBy('name');
return $this->asMenu($query, 'id', ['name', 'client.name'], ' :: ');
}
/**
* Return a menu-friendly list of the user's projects for a single client
*
* @return array
*/
public function projectsByClientForMenu($clientId)
{
$query = $this->client($clientId)->projects()->getQuery();
$query->with('client')->orderBy('name');
return $this->asMenu($query, 'id', ['name', 'client.name'], ' :: ');
}
}
@@ -17,7 +17,9 @@
"filp/whoops": "~2.0",
"fzaninotto/faker": "~1.4",
"mockery/mockery": "~1.0",
"phpmd/phpmd": "^2.6",
"phpunit/phpunit": "~6.0",
"squizlabs/php_codesniffer": "^3.2",
"symfony/thanks": "^1.0"
},
"autoload": {
Oops, something went wrong.

0 comments on commit a044169

Please sign in to comment.