Skip to content
Snippets Groups Projects
Commit 12deee1a authored by Tibo's avatar Tibo
Browse files

add phpcs

parent 6e08c914
No related branches found
No related tags found
No related merge requests found
...@@ -4,16 +4,17 @@ namespace App\Http\Controllers; ...@@ -4,16 +4,17 @@ namespace App\Http\Controllers;
use Cylab\Mark\Client; use Cylab\Mark\Client;
class MarkController extends Controller class MarkController extends Controller
{ {
private $server; private $server;
public function __construct() { public function __construct()
{
$this->server = new Client(); $this->server = new Client();
} }
public function status() { public function status()
{
$status = $this->server->status(); $status = $this->server->status();
$status_history = $this->server->history(); $status_history = $this->server->history();
...@@ -31,22 +32,26 @@ class MarkController extends Controller ...@@ -31,22 +32,26 @@ class MarkController extends Controller
"history_jobs_execution_rate" => $history_jobs_execution_rate]); "history_jobs_execution_rate" => $history_jobs_execution_rate]);
} }
public function pause() { public function pause()
{
$this->server->pause(); $this->server->pause();
return redirect(action('MarkController@status')); return redirect(action('MarkController@status'));
} }
public function resume() { public function resume()
{
$this->server->resume(); $this->server->resume();
return redirect(action('MarkController@status')); return redirect(action('MarkController@status'));
} }
public function reload() { public function reload()
{
$this->server->reload(); $this->server->reload();
return redirect(action('MarkController@status')); return redirect(action('MarkController@status'));
} }
public function ranking(string $label) { public function ranking(string $label)
{
// find the detector corresponding to this label // find the detector corresponding to this label
$detectors = $this->server->activation(); $detectors = $this->server->activation();
...@@ -63,14 +68,17 @@ class MarkController extends Controller ...@@ -63,14 +68,17 @@ class MarkController extends Controller
$now = \Carbon\Carbon::now(); $now = \Carbon\Carbon::now();
return view( return view(
"app.ranking", [ "app.ranking",
[
"label" => $label, "label" => $label,
"evidences" => $evidences, "evidences" => $evidences,
"detector" => $detector, "detector" => $detector,
"now" => $now]); "now" => $now]
);
} }
public function rankingHome() { public function rankingHome()
{
$activation_graph_elements = []; $activation_graph_elements = [];
$activation = $this->server->activation(); $activation = $this->server->activation();
foreach ($activation as $agent) { foreach ($activation as $agent) {
...@@ -92,18 +100,19 @@ class MarkController extends Controller ...@@ -92,18 +100,19 @@ class MarkController extends Controller
{ {
$points = []; $points = [];
foreach ($evidences as $evidence) { foreach ($evidences as $evidence) {
// used by status history // used by status history
// this is dirty :-( // this is dirty :-(
// status history should return an array of objects // status history should return an array of objects
if (is_array($evidence)) { if (is_array($evidence)) {
$points[] = new \App\TimePoint( $points[] = new \App\TimePoint(
$evidence["time"], $evidence["time"],
$evidence[$field]); $evidence[$field]
);
} else { } else {
$points[] = new \App\TimePoint( $points[] = new \App\TimePoint(
$evidence->time, $evidence->time,
$evidence->$field); $evidence->$field
);
} }
} }
return $points; return $points;
...@@ -124,11 +133,13 @@ class MarkController extends Controller ...@@ -124,11 +133,13 @@ class MarkController extends Controller
$history = $this->server->findEvidenceSince($ev->label, $ev->subject, $since); $history = $this->server->findEvidenceSince($ev->label, $ev->subject, $since);
return view( return view(
'app.evidence',[ 'app.evidence',
[
"evidence" => $ev, "evidence" => $ev,
"history" => $history, "history" => $history,
"history_points" => $this->extractPoints($history, "score"), "history_points" => $this->extractPoints($history, "score"),
"references" => $references]); "references" => $references]
);
} }
public function evidenceData(string $id, $data_id) public function evidenceData(string $id, $data_id)
...@@ -150,7 +161,8 @@ class MarkController extends Controller ...@@ -150,7 +161,8 @@ class MarkController extends Controller
* @param array $history_jobs_executed * @param array $history_jobs_executed
* @return array * @return array
*/ */
private function computeExecutionRate(array $history_jobs_executed) : array { private function computeExecutionRate(array $history_jobs_executed) : array
{
$points = []; $points = [];
$last_point_time = $history_jobs_executed[0]->t; $last_point_time = $history_jobs_executed[0]->t;
$last_point_value = $history_jobs_executed[0]->y; $last_point_value = $history_jobs_executed[0]->y;
...@@ -168,7 +180,5 @@ class MarkController extends Controller ...@@ -168,7 +180,5 @@ class MarkController extends Controller
} }
return $points; return $points;
} }
} }
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "c7e38b8f986c30cb6281ffdb450e873f", "content-hash": "014131ad522560e6629d1d02563612fd",
"packages": [ "packages": [
{ {
"name": "asm89/stack-cors", "name": "asm89/stack-cors",
...@@ -7037,6 +7037,57 @@ ...@@ -7037,6 +7037,57 @@
], ],
"time": "2020-07-07T18:42:57+00:00" "time": "2020-07-07T18:42:57+00:00"
}, },
{
"name": "squizlabs/php_codesniffer",
"version": "3.5.6",
"source": {
"type": "git",
"url": "https://github.com/squizlabs/PHP_CodeSniffer.git",
"reference": "e97627871a7eab2f70e59166072a6b767d5834e0"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/e97627871a7eab2f70e59166072a6b767d5834e0",
"reference": "e97627871a7eab2f70e59166072a6b767d5834e0",
"shasum": ""
},
"require": {
"ext-simplexml": "*",
"ext-tokenizer": "*",
"ext-xmlwriter": "*",
"php": ">=5.4.0"
},
"require-dev": {
"phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0"
},
"bin": [
"bin/phpcs",
"bin/phpcbf"
],
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "3.x-dev"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Greg Sherwood",
"role": "lead"
}
],
"description": "PHP_CodeSniffer tokenizes PHP, JavaScript and CSS files and detects violations of a defined set of coding standards.",
"homepage": "https://github.com/squizlabs/PHP_CodeSniffer",
"keywords": [
"phpcs",
"standards"
],
"time": "2020-08-10T04:50:15+00:00"
},
{ {
"name": "symfony/debug", "name": "symfony/debug",
"version": "v4.4.15", "version": "v4.4.15",
......
<?xml version="1.0"?>
<ruleset name="PHP_CodeSniffer">
<description>The coding standard for our project.</description>
<rule ref="PSR2"/>
<file>app</file>
<file>bootstrap</file>
<file>config</file>
<file>database</file>
<file>resources</file>
<file>routes</file>
<file>tests</file>
<exclude-pattern>bootstrap/cache/*</exclude-pattern>
<exclude-pattern>bootstrap/autoload.php</exclude-pattern>
<exclude-pattern>*/migrations/*</exclude-pattern>
<exclude-pattern>*/seeds/*</exclude-pattern>
<exclude-pattern>*.blade.php</exclude-pattern>
<exclude-pattern>*.js</exclude-pattern>
<!-- Show progression -->
<arg value="p"/>
</ruleset>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment