From 435c82471ef5f38d8d231f8506f19da4572302df Mon Sep 17 00:00:00 2001
From: Thibault Debatty <thibault.debatty@gmail.com>
Date: Sat, 20 Apr 2019 22:13:05 +0200
Subject: [PATCH] Add PHP CodeSniffer

---
 web/app/AbstractSensor.php                    | 32 ++++---
 .../Controllers/OrganizationController.php    |  5 +-
 .../OrganizationUserController.php            | 33 ++++---
 web/app/Jobs/StatusChangeDetection.php        |  3 +-
 web/app/Mongo/Facade.php                      |  7 +-
 web/app/Mongo/Service.php                     | 10 ++-
 web/app/Mongo/ServiceProvider.php             | 12 +--
 web/app/Organization.php                      |  6 +-
 web/app/Sensor.php                            |  2 +-
 web/app/Sensor/ClientVersion.php              | 14 +--
 web/app/Sensor/Date.php                       | 13 +--
 web/app/Sensor/Disk.php                       | 18 ++++
 web/app/Sensor/Disks.php                      | 27 +++---
 web/app/Sensor/Heartbeat.php                  | 10 ++-
 web/app/Sensor/Ifconfig.php                   | 58 +++++-------
 web/app/Sensor/Inodes.php                     | 32 +++----
 web/app/Sensor/InodesDisk.php                 | 27 ++++++
 web/app/Sensor/LoadAvg.php                    | 23 +++--
 web/app/Sensor/MemInfo.php                    | 52 +++++------
 web/app/Sensor/Memory.php                     | 33 +++++++
 web/app/Sensor/NetworkInterface.php           | 34 +++++++
 web/app/Sensor/Partition.php                  | 21 +++++
 web/app/Sensor/Point.php                      |  8 +-
 web/app/Sensor/Reboot.php                     | 17 ++--
 web/app/Sensor/Ssacli.php                     | 23 ++---
 web/app/Sensor/Updates.php                    | 13 +--
 web/app/Server.php                            | 89 ++++++++++++-------
 web/app/StatusChange.php                      | 34 ++++---
 web/app/User.php                              |  7 +-
 web/composer.json                             |  3 +-
 web/composer.lock                             | 53 ++++++++++-
 web/phpcs.xml                                 | 24 +++++
 web/routes/api.php                            | 41 +++++----
 web/routes/web.php                            | 30 ++++---
 web/tests/Feature/ExampleTest.php             |  3 +-
 web/tests/Unit/ExampleTest.php                | 48 ++++++----
 36 files changed, 574 insertions(+), 291 deletions(-)
 create mode 100644 web/app/Sensor/Disk.php
 create mode 100644 web/app/Sensor/InodesDisk.php
 create mode 100644 web/app/Sensor/Memory.php
 create mode 100644 web/app/Sensor/NetworkInterface.php
 create mode 100644 web/app/Sensor/Partition.php
 create mode 100644 web/phpcs.xml

diff --git a/web/app/AbstractSensor.php b/web/app/AbstractSensor.php
index 29ab368..8fde5b1 100644
--- a/web/app/AbstractSensor.php
+++ b/web/app/AbstractSensor.php
@@ -7,22 +7,26 @@ namespace App;
  *
  * @author tibo
  */
-abstract class AbstractSensor implements Sensor {
+abstract class AbstractSensor implements Sensor
+{
     /**
      *
      * @var \App\Server
      */
     private $server;
 
-    public function __construct(\App\Server $server) {
+    public function __construct(\App\Server $server)
+    {
         $this->server = $server;
     }
 
-    protected function getServer() {
+    protected function getServer()
+    {
         return $this->server;
     }
 
-    public function getName() : string {
+    public function getName() : string
+    {
         return (new \ReflectionClass($this))->getShortName();
     }
 
@@ -32,7 +36,8 @@ abstract class AbstractSensor implements Sensor {
      * @param string $field
      * @return
      */
-    function getLastRecord (string $field) {
+    public function getLastRecord(string $field)
+    {
         return $this->server->lastRecordContaining($field);
     }
 
@@ -45,10 +50,12 @@ abstract class AbstractSensor implements Sensor {
      * @param type $count
      * @return type
      */
-    function getLastRecords($field, $count) {
+    public function getLastRecords($field, $count)
+    {
         $records = \Mongo::get()->monitoring->records->find(
-                ["server_id" => $this->server->id],
-                ["limit" => $count, "sort" => ["_id" => -1]]);
+            ["server_id" => $this->server->id],
+            ["limit" => $count, "sort" => ["_id" => -1]]
+        );
 
         $results = [];
         foreach ($records as $record) {
@@ -60,7 +67,8 @@ abstract class AbstractSensor implements Sensor {
         return $results;
     }
 
-    public static function getColorForStatus($status) {
+    public static function getColorForStatus($status)
+    {
         switch ($status) {
             case 0:
                 return 'success';
@@ -73,7 +81,8 @@ abstract class AbstractSensor implements Sensor {
         }
     }
 
-    public static function getBadgeForStatus($status) {
+    public static function getBadgeForStatus($status)
+    {
         switch ($status) {
             case 0:
                 return '<span class="badge badge-success">OK</span>';
@@ -86,7 +95,8 @@ abstract class AbstractSensor implements Sensor {
         }
     }
 
-    public function getBadge() {
+    public function getBadge()
+    {
         return self::getBadgeForStatus($this->status());
     }
 }
diff --git a/web/app/Http/Controllers/OrganizationController.php b/web/app/Http/Controllers/OrganizationController.php
index 51a0f33..ac1b1a7 100644
--- a/web/app/Http/Controllers/OrganizationController.php
+++ b/web/app/Http/Controllers/OrganizationController.php
@@ -36,8 +36,9 @@ class OrganizationController extends Controller
     public function index()
     {
         return view(
-                "organization.index",
-                array("organizations" => Auth::user()->organizations->sortBy("name")));
+            "organization.index",
+            array("organizations" => Auth::user()->organizations->sortBy("name"))
+        );
     }
 
     /**
diff --git a/web/app/Http/Controllers/OrganizationUserController.php b/web/app/Http/Controllers/OrganizationUserController.php
index 2a028de..bf9d6bd 100644
--- a/web/app/Http/Controllers/OrganizationUserController.php
+++ b/web/app/Http/Controllers/OrganizationUserController.php
@@ -10,28 +10,34 @@ use Illuminate\Support\Facades\Mail;
 use Illuminate\Support\Facades\Validator;
 use Illuminate\Support\Facades\Auth;
 
-class OrganizationUserController extends Controller {
+class OrganizationUserController extends Controller
+{
 
-    public function __construct() {
+    public function __construct()
+    {
         $this->middleware('auth');
     }
 
-    public function index() {
+    public function index()
+    {
     }
 
     /** Show form **/
-    public function create(Organization $organization) {
+    public function create(Organization $organization)
+    {
         return view("organization.user.create", ["organization" => $organization]);
     }
 
-    protected function validator(array $data) {
+    protected function validator(array $data)
+    {
         return Validator::make($data, [
             'email' => 'required|string|email|max:255|unique:users',
         ]);
     }
 
     /** add user to organization **/
-    public function store(Organization $organization, Request $request) {
+    public function store(Organization $organization, Request $request)
+    {
         $current_user = Auth::user();
         if (! $current_user->ownsOrganization($organization)) {
             return redirect(route("dashboard"));
@@ -59,16 +65,19 @@ class OrganizationUserController extends Controller {
         return redirect(route("dashboard"));
     }
 
-    public function show($id) {
+    public function show($id)
+    {
     }
 
-    public function edit($id) {
+    public function edit($id)
+    {
     }
 
-    public function update($id) {
+    public function update($id)
+    {
     }
 
-    public function destroy($id) {
+    public function destroy($id)
+    {
     }
-
-}
\ No newline at end of file
+}
diff --git a/web/app/Jobs/StatusChangeDetection.php b/web/app/Jobs/StatusChangeDetection.php
index 4a19937..0c9b0eb 100644
--- a/web/app/Jobs/StatusChangeDetection.php
+++ b/web/app/Jobs/StatusChangeDetection.php
@@ -42,7 +42,8 @@ class StatusChangeDetection implements ShouldQueue
         }
     }
 
-    public function detectChangeForServer(Server $server) {
+    public function detectChangeForServer(Server $server)
+    {
         $last_change = StatusChange::getLastChangeForServer($server->id);
         $current_status = $server->status();
 
diff --git a/web/app/Mongo/Facade.php b/web/app/Mongo/Facade.php
index 973c276..fcb81f9 100644
--- a/web/app/Mongo/Facade.php
+++ b/web/app/Mongo/Facade.php
@@ -2,10 +2,11 @@
 
 namespace App\Mongo;
 
-class Facade extends \Illuminate\Support\Facades\Facade {
+class Facade extends \Illuminate\Support\Facades\Facade
+{
 
-    protected static function getFacadeAccessor() {
+    protected static function getFacadeAccessor()
+    {
         return 'mongo';
     }
-
 }
diff --git a/web/app/Mongo/Service.php b/web/app/Mongo/Service.php
index 33dc3f7..89ef2fc 100644
--- a/web/app/Mongo/Service.php
+++ b/web/app/Mongo/Service.php
@@ -4,16 +4,18 @@ namespace App\Mongo;
 
 use MongoDB\Client;
 
-class Service {
+class Service
+{
 
     private $mongo;
 
-    public function __construct($uri = null, $uriOptions = [], $driverOptions = []) {
+    public function __construct($uri = null, $uriOptions = [], $driverOptions = [])
+    {
         $this->mongo = new Client($uri, $uriOptions, $driverOptions);
     }
 
-    public function get() {
+    public function get()
+    {
         return $this->mongo;
     }
-
 }
diff --git a/web/app/Mongo/ServiceProvider.php b/web/app/Mongo/ServiceProvider.php
index 48c1c53..aa37d9e 100644
--- a/web/app/Mongo/ServiceProvider.php
+++ b/web/app/Mongo/ServiceProvider.php
@@ -2,12 +2,14 @@
 
 namespace App\Mongo;
 
-class ServiceProvider extends \Illuminate\Support\ServiceProvider {
+class ServiceProvider extends \Illuminate\Support\ServiceProvider
+{
 
     protected $defer = true;
 
-    public function register() {
-        $this->app->singleton('mongo', function($app) {
+    public function register()
+    {
+        $this->app->singleton('mongo', function ($app) {
             $config = $app->make('config');
             $uri = $config->get('services.mongo.uri');
             $uriOptions = $config->get('services.mongo.uriOptions');
@@ -16,8 +18,8 @@ class ServiceProvider extends \Illuminate\Support\ServiceProvider {
         });
     }
 
-    public function provides() {
+    public function provides()
+    {
         return ['mongo'];
     }
-
 }
diff --git a/web/app/Organization.php b/web/app/Organization.php
index 0af1e10..06a2dcb 100644
--- a/web/app/Organization.php
+++ b/web/app/Organization.php
@@ -8,11 +8,13 @@ class Organization extends Model
 {
 
 
-    public function users() {
+    public function users()
+    {
         return $this->belongsToMany("App\User");
     }
 
-    public function servers() {
+    public function servers()
+    {
         return $this->hasMany("App\Server");
     }
 }
diff --git a/web/app/Sensor.php b/web/app/Sensor.php
index b63e36c..e6477c5 100644
--- a/web/app/Sensor.php
+++ b/web/app/Sensor.php
@@ -18,4 +18,4 @@ interface Sensor
      * @return string
      */
     public function getName() : string;
-}
\ No newline at end of file
+}
diff --git a/web/app/Sensor/ClientVersion.php b/web/app/Sensor/ClientVersion.php
index 29fcef8..139dae8 100644
--- a/web/app/Sensor/ClientVersion.php
+++ b/web/app/Sensor/ClientVersion.php
@@ -7,14 +7,16 @@ namespace App\Sensor;
  *
  * @author tibo
  */
-class ClientVersion extends \App\AbstractSensor {
+class ClientVersion extends \App\AbstractSensor
+{
 
     const MANIFEST = "https://gitlab.cylab.be/cylab/monitoring/raw/master/php-client/release/manifest.json";
 
-    public function latestVersion() {
+    public function latestVersion()
+    {
         $ctx = stream_context_create(array('http' => ['timeout' => 5]));
         $json = @ \file_get_contents(self::MANIFEST, false, $ctx);
-        if ($json === FALSE) {
+        if ($json === false) {
             return "";
         }
 
@@ -22,12 +24,14 @@ class ClientVersion extends \App\AbstractSensor {
     }
 
     //put your code here
-    public function report() {
+    public function report()
+    {
         return "<p>Installed version: " . $this->getServer()->clientVersion() . "</p>"
         . "<p>Latest client version: " . $this->latestVersion() . "</p>";
     }
 
-    public function status() {
+    public function status()
+    {
         if ($this->getServer()->clientVersion() === $this->latestVersion()) {
             return self::STATUS_OK;
         }
diff --git a/web/app/Sensor/Date.php b/web/app/Sensor/Date.php
index b62fcdb..b6cac4d 100644
--- a/web/app/Sensor/Date.php
+++ b/web/app/Sensor/Date.php
@@ -13,15 +13,18 @@ namespace App\Sensor;
  *
  * @author tibo
  */
-class Date extends \App\AbstractSensor {
+class Date extends \App\AbstractSensor
+{
     //put your code here
-    public function report() {
+    public function report()
+    {
         return "<p>Time drift: " . $this->delta() . " seconds</p>";
     }
 
 
 
-    public function status() {
+    public function status()
+    {
         $delta = $this->delta();
         if ($delta == null) {
             return self::STATUS_UNKNOWN;
@@ -34,7 +37,8 @@ class Date extends \App\AbstractSensor {
         return self::STATUS_OK;
     }
 
-    public function delta() {
+    public function delta()
+    {
         $record = $this->getLastRecord("date");
         if ($record === null) {
             return null;
@@ -42,5 +46,4 @@ class Date extends \App\AbstractSensor {
 
         return $record->date - $record->time;
     }
-
 }
diff --git a/web/app/Sensor/Disk.php b/web/app/Sensor/Disk.php
new file mode 100644
index 0000000..2600702
--- /dev/null
+++ b/web/app/Sensor/Disk.php
@@ -0,0 +1,18 @@
+<?php
+
+namespace App\Sensor;
+
+/**
+ * Description of Disk
+ *
+ * @author tibo
+ */
+class Disk
+{
+    public $port = "";
+    public $box = 0;
+    public $bay = 0;
+    public $type = "";
+    public $size = "";
+    public $status = "";
+}
diff --git a/web/app/Sensor/Disks.php b/web/app/Sensor/Disks.php
index 2bb3e65..06c1a4c 100644
--- a/web/app/Sensor/Disks.php
+++ b/web/app/Sensor/Disks.php
@@ -7,11 +7,13 @@ namespace App\Sensor;
  *
  * @author tibo
  */
-class Disks extends \App\AbstractSensor {
+class Disks extends \App\AbstractSensor
+{
 
     const REGEXP = "/\\n([A-z\/0-9:\\-\\.]+)\s*([0-9]+)\s*([0-9]+)\s*([0-9]+)\s*([0-9]+)%\s*([A-z\/0-9]+)/";
 
-    public function report() {
+    public function report()
+    {
         $record = $this->getLastRecord("disks");
         if ($record == null) {
             return "<p>No data available...</p>";
@@ -21,13 +23,16 @@ class Disks extends \App\AbstractSensor {
         $return = "<table class='table table-sm'>";
         $return .= "<tr><th></th><th></th><th>Usage</th></tr>";
         foreach ($partitions as $partition) {
-            $return .= "<tr><td>" . $partition->filesystem . "</td><td>" . $partition->mounted . "</td><td>" . $partition->usedPercent() . "%</td></tr>";
+            $return .= "<tr><td>" . $partition->filesystem . "</td><td>"
+                    . $partition->mounted . "</td><td>" . $partition->usedPercent()
+                    . "%</td></tr>";
         }
         $return .= "</table>";
         return $return;
     }
 
-    public function status() {
+    public function status()
+    {
         $record = $this->getLastRecord("disks");
         if ($record == null) {
             return self::STATUS_UNKNOWN;
@@ -50,7 +55,8 @@ class Disks extends \App\AbstractSensor {
 
     public static $skip_fs = ["none", "tmpfs", "shm"];
 
-    public function parse($string) {
+    public function parse($string)
+    {
         $values = array();
         preg_match_all(self::REGEXP, $string, $values);
         $partitions = array();
@@ -71,14 +77,3 @@ class Disks extends \App\AbstractSensor {
         return $partitions;
     }
 }
-
-class Partition {
-    public $filesystem = "";
-    public $blocks = 0;
-    public $used = 0;
-    public $mounted = "";
-
-    public function usedPercent() {
-        return round(100.0 * $this->used / $this->blocks);
-    }
-}
diff --git a/web/app/Sensor/Heartbeat.php b/web/app/Sensor/Heartbeat.php
index 3962d05..b6aafba 100644
--- a/web/app/Sensor/Heartbeat.php
+++ b/web/app/Sensor/Heartbeat.php
@@ -13,20 +13,22 @@ namespace App\Sensor;
  *
  * @author tibo
  */
-class Heartbeat extends \App\AbstractSensor {
+class Heartbeat extends \App\AbstractSensor
+{
     //put your code here
-    public function report() {
+    public function report()
+    {
         return "<p>Last heartbeat received "
         . $this->getServer()->lastRecordTime()->diffForHumans() . "</p>";
     }
 
 
-    public function status() {
+    public function status()
+    {
         $record = $this->getServer()->lastRecord();
 
         if ($record === null) {
             $delta = PHP_INT_MAX;
-
         } else {
             $delta = \time() - $record->time;
         }
diff --git a/web/app/Sensor/Ifconfig.php b/web/app/Sensor/Ifconfig.php
index 754e218..289648c 100644
--- a/web/app/Sensor/Ifconfig.php
+++ b/web/app/Sensor/Ifconfig.php
@@ -9,9 +9,11 @@ use \App\AbstractSensor;
  *
  * @author tibo
  */
-class Ifconfig extends AbstractSensor {
+class Ifconfig extends AbstractSensor
+{
 
-    public function report() {
+    public function report()
+    {
 
         $interfaces = [];
         $record = $this->getLastRecord("ifconfig");
@@ -23,10 +25,11 @@ class Ifconfig extends AbstractSensor {
             "interfaces" => $interfaces]);
     }
 
-    public function points() {
+    public function points()
+    {
         // Get records in time ascending order
         $records = $this->getLastRecords("ifconfig", 289);
-        usort($records, function($r1, $r2) {
+        usort($records, function ($r1, $r2) {
             return $r1->time  > $r2->time ? 1 : -1;
         });
 
@@ -66,8 +69,9 @@ class Ifconfig extends AbstractSensor {
                     $delta = 0;
                 }
                 $dataset[$iname . "/RX"]["points"][] = new Point(
-                        $interface->time * 1000,
-                        round(8 / 1024 * $delta / $delta_time));
+                    $interface->time * 1000,
+                    round(8 / 1024 * $delta / $delta_time)
+                );
 
                 // TX
                 $delta = $interface->tx - $previous_value->tx;
@@ -76,20 +80,20 @@ class Ifconfig extends AbstractSensor {
                     $delta = 0;
                 }
                 $dataset[$iname . "/TX"]["points"][] = new Point(
-                        $interface->time * 1000,
-                        round(8 / 1024 * $delta / $delta_time));
+                    $interface->time * 1000,
+                    round(8 / 1024 * $delta / $delta_time)
+                );
 
                 // Keep current value for next record
                 $current_value[$iname] = $interface;
-
             }
         }
 
         return array_values($dataset);
-
     }
 
-    public function status() {
+    public function status()
+    {
         return self::STATUS_OK;
     }
 
@@ -97,7 +101,8 @@ class Ifconfig extends AbstractSensor {
     const IPV4 = '/^\\s+inet addr:(\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3})/m';
     const RXTX = '/^\\s+RX bytes:(\\d+) .*TX bytes:(\\d+)/m';
 
-    public function parseIfconfigRecord($record) {
+    public function parseIfconfigRecord($record)
+    {
         $interfaces = $this->parseIfconfig($record->ifconfig);
         foreach ($interfaces as $interface) {
             $interface->time = $record->time;
@@ -112,7 +117,8 @@ class Ifconfig extends AbstractSensor {
      * @param type $string
      * @return \App\Sensor\NetworkInterface[]
      */
-    public function parseIfconfig($string) {
+    public function parseIfconfig($string)
+    {
 
         $allowed_prefixes = ["en", "eth", "wl"];
 
@@ -158,7 +164,8 @@ class Ifconfig extends AbstractSensor {
         return $filtered;
     }
 
-    public function pregMatchOne($pattern, $string) {
+    public function pregMatchOne($pattern, $string)
+    {
         $matches = array();
         if (preg_match($pattern, $string, $matches) === 1) {
             return $matches[1];
@@ -167,26 +174,3 @@ class Ifconfig extends AbstractSensor {
         return false;
     }
 }
-
-class NetworkInterface {
-    public $name;
-    public $address;
-    public $rx;
-    public $tx;
-    public $time;
-
-    public function humanReadableSize($bytes, $decimals = 2) {
-        $size = array('B', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB');
-        $factor = floor((strlen($bytes) - 1) / 3);
-        return sprintf("%.{$decimals}f", $bytes / pow(1024, $factor)) . @$size[$factor];
-    }
-
-    public function humanReadableRx() {
-        return $this->humanReadableSize($this->rx);
-    }
-
-    public function humanReadableTx() {
-        return $this->humanReadableSize($this->tx);
-    }
-
-}
diff --git a/web/app/Sensor/Inodes.php b/web/app/Sensor/Inodes.php
index efb677c..ccbf41d 100644
--- a/web/app/Sensor/Inodes.php
+++ b/web/app/Sensor/Inodes.php
@@ -7,11 +7,13 @@ namespace App\Sensor;
  *
  * @author tibo
  */
-class Inodes extends \App\AbstractSensor {
+class Inodes extends \App\AbstractSensor
+{
 
     const REGEXP = "/\\n([A-z\/0-9:\\-\\.]+)\s*([0-9]+)\s*([0-9]+)\s*([0-9]+)\s*([0-9]+)%\s*([A-z\/0-9]+)/";
 
-    public function report() {
+    public function report()
+    {
         $record = $this->getLastRecord("inodes");
         if ($record == null) {
             return "<p>No data availabe...</p>";
@@ -21,14 +23,16 @@ class Inodes extends \App\AbstractSensor {
         $return = "<table class='table table-sm'>";
         $return .= "<tr><th></th><th></th><th>Usage</th></tr>";
         foreach ($disks as $disk) {
-            $return .= "<tr><td>" . $disk->filesystem . "</td><td>" . $disk->mounted . "</td><td>" . $disk->usedPercent() . "%</td></tr>";
+            $return .= "<tr><td>" . $disk->filesystem . "</td><td>"
+                    . $disk->mounted . "</td><td>" . $disk->usedPercent()
+                    . "%</td></tr>";
         }
         $return .= "</table>";
         return $return;
-
     }
 
-    public function status() {
+    public function status()
+    {
         $record = $this->getLastRecord("inodes");
         if ($record == null) {
             return self::STATUS_UNKNOWN;
@@ -36,7 +40,7 @@ class Inodes extends \App\AbstractSensor {
 
         $all_status = [];
         foreach ($this->parse($record->inodes) as $disk) {
-            /* @var $disk DiskInodes */
+            /* @var $disk InodesDisk */
             $status = self::STATUS_OK;
             if ($disk->usedPercent() > 80) {
                 $status = self::STATUS_WARNING;
@@ -49,7 +53,8 @@ class Inodes extends \App\AbstractSensor {
         return max($all_status);
     }
 
-    public function parse($string) {
+    public function parse($string)
+    {
         $values = array();
         preg_match_all(self::REGEXP, $string, $values);
         $disks = array();
@@ -60,7 +65,7 @@ class Inodes extends \App\AbstractSensor {
                 continue;
             }
 
-            $disk = new DiskInodes();
+            $disk = new InodesDisk();
             $disk->filesystem = $values[1][$i];
             $disk->inodes = $values[2][$i];
             $disk->used = $values[3][$i];
@@ -70,14 +75,3 @@ class Inodes extends \App\AbstractSensor {
         return $disks;
     }
 }
-
-class DiskInodes {
-    public $filesystem = "";
-    public $inodes = 0;
-    public $used = 0;
-    public $mounted = "";
-
-    public function usedPercent() {
-        return round(100.0 * $this->used / $this->inodes);
-    }
-}
diff --git a/web/app/Sensor/InodesDisk.php b/web/app/Sensor/InodesDisk.php
new file mode 100644
index 0000000..54d708c
--- /dev/null
+++ b/web/app/Sensor/InodesDisk.php
@@ -0,0 +1,27 @@
+<?php
+
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+namespace App\Sensor;
+
+/**
+ * Description of InodesDisk
+ *
+ * @author tibo
+ */
+class InodesDisk
+{
+    public $filesystem = "";
+    public $inodes = 0;
+    public $used = 0;
+    public $mounted = "";
+
+    public function usedPercent()
+    {
+        return round(100.0 * $this->used / $this->inodes);
+    }
+}
diff --git a/web/app/Sensor/LoadAvg.php b/web/app/Sensor/LoadAvg.php
index c420312..66130b4 100644
--- a/web/app/Sensor/LoadAvg.php
+++ b/web/app/Sensor/LoadAvg.php
@@ -4,36 +4,42 @@ namespace App\Sensor;
 
 use \App\AbstractSensor;
 
-
 /**
  * Description of LoadAvg
  *
  * @author tibo
  */
-class LoadAvg extends AbstractSensor {
+class LoadAvg extends AbstractSensor
+{
 
-    public function report() {
+    public function report()
+    {
         return view("agent.loadavg", [
             "current_load" => $this->getLastValue(),
             "server" => $this->getServer()]);
     }
 
-    public function loadPoints() {
+    public function loadPoints()
+    {
         $records = $this->getLastRecords("loadavg", 288);
 
         $points = [];
         foreach ($records as $record) {
             $points[] = new Point(
-                    $record->time * 1000, $this->parse($record->loadavg));
+                $record->time * 1000,
+                $this->parse($record->loadavg)
+            );
         }
         return $points;
     }
 
-    public function status() {
+    public function status()
+    {
         return self::STATUS_OK;
     }
 
-    public function getLastValue() {
+    public function getLastValue()
+    {
         $record = $this->getLastRecord("loadavg");
         if ($record == null) {
             return "no data...";
@@ -42,7 +48,8 @@ class LoadAvg extends AbstractSensor {
         return $this->parse($field);
     }
 
-    function parse($string) {
+    public function parse($string)
+    {
         return current(explode(" ", $string));
     }
 }
diff --git a/web/app/Sensor/MemInfo.php b/web/app/Sensor/MemInfo.php
index 6454b3f..5fece76 100644
--- a/web/app/Sensor/MemInfo.php
+++ b/web/app/Sensor/MemInfo.php
@@ -9,40 +9,49 @@ use \App\AbstractSensor;
  *
  * @author tibo
  */
-class MemInfo extends AbstractSensor {
+class MemInfo extends AbstractSensor
+{
 
-    public function report() {
+    public function report()
+    {
 
         return view("agent.meminfo", ["server" => $this->getServer()]);
     }
 
-    public function usedMemoryPoints() {
+    public function usedMemoryPoints()
+    {
         $records = $this->getLastRecords("memory", 288);
 
         $used = [];
         foreach ($records as $record) {
             $meminfo = $this->parseMeminfo($record->memory);
             $used[] = new Point(
-                    $record->time * 1000, $meminfo->used() / 1000);
+                $record->time * 1000,
+                $meminfo->used() / 1000
+            );
         }
 
         return $used;
     }
 
-    public function cachedMemoryPoints() {
+    public function cachedMemoryPoints()
+    {
         $records = $this->getLastRecords("memory", 288);
 
         $points = [];
         foreach ($records as $record) {
             $meminfo = $this->parseMeminfo($record->memory);
             $points[] = new Point(
-                    $record->time * 1000, $meminfo->cached / 1000);
+                $record->time * 1000,
+                $meminfo->cached / 1000
+            );
         }
 
         return $points;
     }
 
-    public function status() {
+    public function status()
+    {
         return self::STATUS_OK;
     }
 
@@ -51,32 +60,19 @@ class MemInfo extends AbstractSensor {
     const MEMFREE = "/^MemFree:\\s+([0-9]+) kB$/m";
     const MEMCACHED = "/^Cached:\\s+([0-9]+) kB$/m";
 
-    public function parseMeminfo($string) {
+    public function parseMeminfo($string)
+    {
         return new Memory(
-                $this->pregMatchOne(self::MEMTOTAL, $string),
-                $this->pregMatchOne(self::MEMFREE, $string),
-                $this->pregMatchOne(self::MEMCACHED, $string));
+            $this->pregMatchOne(self::MEMTOTAL, $string),
+            $this->pregMatchOne(self::MEMFREE, $string),
+            $this->pregMatchOne(self::MEMCACHED, $string)
+        );
     }
 
-    public function pregMatchOne($pattern, $string) {
+    public function pregMatchOne($pattern, $string)
+    {
         $matches = array();
         preg_match($pattern, $string, $matches);
         return $matches[1];
     }
 }
-
-class Memory {
-    public $total;
-    public $free;
-    public $cached;
-
-    public function __construct($total, $free, $cached) {
-        $this->total = $total;
-        $this->free = $free;
-        $this->cached = $cached;
-    }
-
-    public function used() {
-        return $this->total - $this->free - $this->cached;
-    }
-}
diff --git a/web/app/Sensor/Memory.php b/web/app/Sensor/Memory.php
new file mode 100644
index 0000000..fd0025b
--- /dev/null
+++ b/web/app/Sensor/Memory.php
@@ -0,0 +1,33 @@
+<?php
+
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+namespace App\Sensor;
+
+/**
+ * Description of Memory
+ *
+ * @author tibo
+ */
+class Memory
+{
+    public $total;
+    public $free;
+    public $cached;
+
+    public function __construct($total, $free, $cached)
+    {
+        $this->total = $total;
+        $this->free = $free;
+        $this->cached = $cached;
+    }
+
+    public function used()
+    {
+        return $this->total - $this->free - $this->cached;
+    }
+}
diff --git a/web/app/Sensor/NetworkInterface.php b/web/app/Sensor/NetworkInterface.php
new file mode 100644
index 0000000..016e264
--- /dev/null
+++ b/web/app/Sensor/NetworkInterface.php
@@ -0,0 +1,34 @@
+<?php
+
+namespace App\Sensor;
+
+/**
+ * Description of NetworkInterface
+ *
+ * @author tibo
+ */
+class NetworkInterface
+{
+    public $name;
+    public $address;
+    public $rx;
+    public $tx;
+    public $time;
+
+    public function humanReadableSize($bytes, $decimals = 2)
+    {
+        $size = array('B', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB');
+        $factor = floor((strlen($bytes) - 1) / 3);
+        return sprintf("%.{$decimals}f", $bytes / pow(1024, $factor)) . @$size[$factor];
+    }
+
+    public function humanReadableRx()
+    {
+        return $this->humanReadableSize($this->rx);
+    }
+
+    public function humanReadableTx()
+    {
+        return $this->humanReadableSize($this->tx);
+    }
+}
diff --git a/web/app/Sensor/Partition.php b/web/app/Sensor/Partition.php
new file mode 100644
index 0000000..54d4417
--- /dev/null
+++ b/web/app/Sensor/Partition.php
@@ -0,0 +1,21 @@
+<?php
+
+namespace App\Sensor;
+
+/**
+ * Description of Partition
+ *
+ * @author tibo
+ */
+class Partition
+{
+    public $filesystem = "";
+    public $blocks = 0;
+    public $used = 0;
+    public $mounted = "";
+
+    public function usedPercent()
+    {
+        return round(100.0 * $this->used / $this->blocks);
+    }
+}
diff --git a/web/app/Sensor/Point.php b/web/app/Sensor/Point.php
index e3b35a4..bda9c13 100644
--- a/web/app/Sensor/Point.php
+++ b/web/app/Sensor/Point.php
@@ -8,12 +8,14 @@ namespace App\Sensor;
  * @author tibo
  */
 
-class Point {
+class Point
+{
     public $t = 0;
     public $y = 0;
 
-    public function __construct($t, $y) {
+    public function __construct($t, $y)
+    {
         $this->t = $t;
         $this->y = $y;
     }
-}
\ No newline at end of file
+}
diff --git a/web/app/Sensor/Reboot.php b/web/app/Sensor/Reboot.php
index 41867ca..70a1bd8 100644
--- a/web/app/Sensor/Reboot.php
+++ b/web/app/Sensor/Reboot.php
@@ -13,20 +13,23 @@ namespace App\Sensor;
  *
  * @author tibo
  */
-class Reboot extends \App\AbstractSensor {
+class Reboot extends \App\AbstractSensor
+{
     //put your code here
-    public function report() {
+    public function report()
+    {
         return "<p>Reboot required: "
             . $this->statusHTML()
             . "</p>";
     }
 
-    function statusHTML() {
+    public function statusHTML()
+    {
         switch ($this->status()) {
-            case self::STATUS_OK :
+            case self::STATUS_OK:
                 return "no";
 
-            case self::STATUS_WARNING :
+            case self::STATUS_WARNING:
                 return "yes";
 
             default:
@@ -34,7 +37,8 @@ class Reboot extends \App\AbstractSensor {
         }
     }
 
-    public function status() {
+    public function status()
+    {
         $record = $this->getLastRecord("reboot");
         if ($record === null) {
             return self::STATUS_UNKNOWN;
@@ -46,5 +50,4 @@ class Reboot extends \App\AbstractSensor {
 
         return self::STATUS_OK;
     }
-
 }
diff --git a/web/app/Sensor/Ssacli.php b/web/app/Sensor/Ssacli.php
index 54fc6b7..78f93a7 100644
--- a/web/app/Sensor/Ssacli.php
+++ b/web/app/Sensor/Ssacli.php
@@ -13,10 +13,12 @@ namespace App\Sensor;
  *
  * @author tibo
  */
-class Ssacli extends \App\AbstractSensor {
+class Ssacli extends \App\AbstractSensor
+{
     const REGEXP = "/\s*physicaldrive .*\(port (.*):box (\d*):bay (\d*), (.*), (.*), (\w*)\)/";
 
-    public function report() {
+    public function report()
+    {
         $record = $this->getLastRecord("ssacli");
         if ($record == null) {
             return "<p>No data available...</p>";
@@ -46,7 +48,8 @@ class Ssacli extends \App\AbstractSensor {
         return $return;
     }
 
-    public function status() {
+    public function status()
+    {
         $record = $this->getLastRecord("ssacli");
         if ($record == null) {
             return self::STATUS_UNKNOWN;
@@ -60,7 +63,6 @@ class Ssacli extends \App\AbstractSensor {
         }
 
         return self::STATUS_OK;
-
     }
 
     /**
@@ -68,7 +70,8 @@ class Ssacli extends \App\AbstractSensor {
      * @param type $string
      * @return \App\Sensor\Disk[]
      */
-    public function parse($string) {
+    public function parse($string)
+    {
         $values = array();
         preg_match_all(self::REGEXP, $string, $values);
         $disks = array();
@@ -86,13 +89,3 @@ class Ssacli extends \App\AbstractSensor {
         return $disks;
     }
 }
-
-
-class Disk {
-    public $port = "";
-    public $box = 0;
-    public $bay = 0;
-    public $type = "";
-    public $size = "";
-    public $status = "";
-}
\ No newline at end of file
diff --git a/web/app/Sensor/Updates.php b/web/app/Sensor/Updates.php
index 43add6a..3484866 100644
--- a/web/app/Sensor/Updates.php
+++ b/web/app/Sensor/Updates.php
@@ -7,11 +7,13 @@ namespace App\Sensor;
  *
  * @author tibo
  */
-class Updates extends \App\AbstractSensor {
+class Updates extends \App\AbstractSensor
+{
 
     const REGEXP = "/(\d+)\spackages? can be updated\.\n(\d+)\supdates are security updates./";
 
-    public function report() {
+    public function report()
+    {
         $record = $this->getLastRecord("updates");
         if ($record == null) {
             return "<p>No data availabe...</p>";
@@ -20,7 +22,8 @@ class Updates extends \App\AbstractSensor {
         return "<p>" . nl2br($record->updates) . "</p>";
     }
 
-    public function status() {
+    public function status()
+    {
         $record = $this->getLastRecord("updates");
         if ($record == null) {
             return self::STATUS_UNKNOWN;
@@ -38,7 +41,8 @@ class Updates extends \App\AbstractSensor {
         return self::STATUS_OK;
     }
 
-    public function parse($string) {
+    public function parse($string)
+    {
         $matches = [];
         if (!preg_match(self::REGEXP, $string, $matches)) {
             return null;
@@ -48,5 +52,4 @@ class Updates extends \App\AbstractSensor {
         $result["security"] = $matches[2];
         return $result;
     }
-
 }
diff --git a/web/app/Server.php b/web/app/Server.php
index 3189521..59d60de 100644
--- a/web/app/Server.php
+++ b/web/app/Server.php
@@ -15,7 +15,7 @@ class Server extends Model
      */
     private $last_record = null;
 
-    static $sensors = [
+    private static $sensors = [
         \App\Sensor\LoadAvg::class,
         \App\Sensor\MemInfo::class,
         \App\Sensor\Ifconfig::class,
@@ -29,22 +29,25 @@ class Server extends Model
         \App\Sensor\Heartbeat::class
     ];
 
-    public function __construct(array $attributes = array()) {
+    public function __construct(array $attributes = array())
+    {
         $attributes["token"] = str_random(32);
         parent::__construct($attributes);
     }
 
-    public function organization() {
+    public function organization()
+    {
         return $this->belongsTo("App\Organization");
     }
 
-    public function lastRecord() {
+    public function lastRecord()
+    {
         if ($this->last_record == null) {
-
             $collection = \Mongo::get()->monitoring->records;
             $this->last_record =  $collection->findOne(
-                    ["server_id" => $this->id],
-                    ["sort" => ["_id" => -1]]);
+                ["server_id" => $this->id],
+                ["sort" => ["_id" => -1]]
+            );
         }
 
         return $this->last_record;
@@ -56,7 +59,8 @@ class Server extends Model
      * @param string $field
      * @return string
      */
-    public function lastRecordContaining(string $field) {
+    public function lastRecordContaining(string $field)
+    {
         if (isset($this->lastRecord()->$field)) {
             return $this->lastRecord();
         }
@@ -68,7 +72,8 @@ class Server extends Model
      *
      * @return \Carbon\Carbon
      */
-    public function lastRecordTime() {
+    public function lastRecordTime()
+    {
         $last_record = $this->lastRecord();
         if ($last_record === null) {
             return \Carbon\Carbon::createFromTimestamp(0);
@@ -77,7 +82,8 @@ class Server extends Model
         return \Carbon\Carbon::createFromTimestamp($last_record->time);
     }
 
-    public function clientVersion() {
+    public function clientVersion()
+    {
         $last_record = $this->lastRecord();
         if ($last_record == null) {
             return "none";
@@ -90,15 +96,18 @@ class Server extends Model
      * Get integer status of server.
      * @return int
      */
-    public function status() {
+    public function status()
+    {
         return max($this->statusArray());
     }
 
-    public function statusBadge() {
+    public function statusBadge()
+    {
         return AbstractSensor::getBadgeForStatus($this->status());
     }
 
-    public function statusArray() {
+    public function statusArray()
+    {
         $status_array = [];
         foreach ($this->getSensors() as $sensor) {
             $status_array[\get_class($sensor)] = $sensor->status();
@@ -106,7 +115,8 @@ class Server extends Model
         return $status_array;
     }
 
-    public function getSensorsNOK() {
+    public function getSensorsNOK()
+    {
         $sensorsNOK = [];
         foreach ($this->getSensors() as $sensor) {
             if ($sensor->status() > 0) {
@@ -116,7 +126,8 @@ class Server extends Model
         return $sensorsNOK;
     }
 
-    public function statusString() {
+    public function statusString()
+    {
         switch ($this->status()) {
             case 0:
                 return "OK";
@@ -129,15 +140,18 @@ class Server extends Model
         }
     }
 
-    public function getBadge() {
+    public function getBadge()
+    {
         return AbstractSensor::getBadgeForStatus($this->status());
     }
 
-    public function color() {
+    public function color()
+    {
         return AbstractSensor::getColorForStatus($this->status());
     }
 
-    public function getSensors() {
+    public function getSensors()
+    {
 
         $sensors = [];
         foreach (self::$sensors as $sensor) {
@@ -148,7 +162,8 @@ class Server extends Model
 
 
 
-    public function cpuinfo() {
+    public function cpuinfo()
+    {
         $record = $this->lastRecordContaining("cpu");
         if ($record == null) {
             return null;
@@ -158,7 +173,8 @@ class Server extends Model
     }
 
     const CPU_INFO = "/^model name	: (.+)$/m";
-    public function parseCpuinfo($string) {
+    public function parseCpuinfo($string)
+    {
         $matches = array();
         preg_match_all(self::CPU_INFO, $string, $matches);
 
@@ -167,7 +183,8 @@ class Server extends Model
         return $result;
     }
 
-    public function meminfo() {
+    public function meminfo()
+    {
         return round($this->memoryTotal() / 1000 / 1000) . " GB";
     }
 
@@ -175,7 +192,8 @@ class Server extends Model
      *
      * @return int total memory (in KB)
      */
-    public function memoryTotal() {
+    public function memoryTotal()
+    {
         $record = $this->lastRecordContaining("memory");
         if ($record == null) {
             return null;
@@ -185,14 +203,16 @@ class Server extends Model
     }
 
     const MEMINFO = "/^MemTotal:\\s+([0-9]+) kB$/m";
-    public function parseMeminfo($string) {
+    public function parseMeminfo($string)
+    {
         $matches = array();
         preg_match(self::MEMINFO, $string, $matches);
         $total = $matches[1];
         return $total;
     }
 
-    public function lsb() {
+    public function lsb()
+    {
 
         $record = $this->lastRecordContaining("lsb");
         if ($record == null) {
@@ -203,7 +223,8 @@ class Server extends Model
     }
 
     const LSB = "/^Description:	(.+)$/m";
-    public function parseLsb($string) {
+    public function parseLsb($string)
+    {
         $matches = [];
         preg_match(self::LSB, $string, $matches);
         return $matches[1];
@@ -212,13 +233,15 @@ class Server extends Model
 
 
     const REGEX_MANUFACTURER = "/^\s*Manufacturer: (.*)$/m";
-    public function parseManufacturer($string) {
+    public function parseManufacturer($string)
+    {
         $matches = [];
         preg_match(self::REGEX_MANUFACTURER, $string, $matches);
         return $matches[1];
     }
 
-    public function manufacturer() {
+    public function manufacturer()
+    {
         $record = $this->lastRecordContaining("system");
         if ($record == null) {
             return "Unknown";
@@ -228,13 +251,15 @@ class Server extends Model
     }
 
     const REGEX_PRODUCT_NAME = "/^\s*Product Name: (.*)$/m";
-    public function parseProductName($string) {
+    public function parseProductName($string)
+    {
         $matches = [];
         preg_match(self::REGEX_PRODUCT_NAME, $string, $matches);
         return $matches[1];
     }
 
-    public function productName() {
+    public function productName()
+    {
         $record = $this->lastRecordContaining("system");
         if ($record == null) {
             return "";
@@ -243,11 +268,13 @@ class Server extends Model
         return $this->parseProductName($record->system);
     }
 
-    public function getChanges($count = 10) {
+    public function getChanges($count = 10)
+    {
         return \App\StatusChange::getLastChangesForServer($this->id, $count);
     }
 
-    public static function id($id) : Server {
+    public static function id($id) : Server
+    {
         return self::where("id", $id)->first();
     }
 }
diff --git a/web/app/StatusChange.php b/web/app/StatusChange.php
index 896a10d..f1b0953 100644
--- a/web/app/StatusChange.php
+++ b/web/app/StatusChange.php
@@ -9,13 +9,15 @@ use \Carbon\Carbon;
  *
  * @author tibo
  */
-class StatusChange {
+class StatusChange
+{
 
     public $server_id = 0;
     public $status = 0;
     public $time = 0;
 
-    public function parse($array) {
+    public function parse($array)
+    {
         if ($array == null) {
             return;
         }
@@ -30,19 +32,23 @@ class StatusChange {
         return $this;
     }
 
-    public function getStatusBadge() {
+    public function getStatusBadge()
+    {
         return AbstractSensor::getBadgeForStatus($this->status);
     }
 
-    public function getTimeCarbon() : Carbon {
+    public function getTimeCarbon() : Carbon
+    {
         return Carbon::createFromTimestamp($this->time);
     }
 
-    public function server() : Server {
+    public function server() : Server
+    {
         return Server::id($this->server_id);
     }
 
-    public static function save($status) {
+    public static function save($status)
+    {
         $data = [
             "time" => time(),
             "server_id" => $status->server_id,
@@ -54,11 +60,13 @@ class StatusChange {
         $collection->insertOne($data);
     }
 
-    public static function getLastChangesForServer(int $server_id, int $count) : array {
+    public static function getLastChangesForServer(int $server_id, int $count) : array
+    {
         $collection = \Mongo::get()->monitoring->statuschanges;
         $records = $collection->find(
-                    ["server_id" => $server_id],
-                    ["limit" => $count, "sort" => ["_id" => -1]]);
+            ["server_id" => $server_id],
+            ["limit" => $count, "sort" => ["_id" => -1]]
+        );
 
         $changes = [];
         foreach ($records as $record) {
@@ -67,11 +75,13 @@ class StatusChange {
         return $changes;
     }
 
-    public static function getLastChangeForServer(int $server_id) : StatusChange {
+    public static function getLastChangeForServer(int $server_id) : StatusChange
+    {
         $collection = \Mongo::get()->monitoring->statuschanges;
         $record = $collection->findOne(
-                    ["server_id" => $server_id],
-                    ["sort" => ["_id" => -1]]);
+            ["server_id" => $server_id],
+            ["sort" => ["_id" => -1]]
+        );
 
         $change = new StatusChange();
         $change->server_id = $server_id;
diff --git a/web/app/User.php b/web/app/User.php
index b997182..6d108fa 100644
--- a/web/app/User.php
+++ b/web/app/User.php
@@ -32,7 +32,8 @@ class User extends Authenticatable
         return $this->belongsToMany('App\Organization');
     }
 
-    public function ownsOrganization(Organization $organization) {
+    public function ownsOrganization(Organization $organization)
+    {
         foreach ($this->organizations as $o) {
             if ($o->id == $organization->id) {
                 return true;
@@ -42,8 +43,8 @@ class User extends Authenticatable
         return false;
     }
 
-    public static function findByEmail($email) {
+    public static function findByEmail($email)
+    {
         return self::where("email", $email)->first();
     }
-
 }
diff --git a/web/composer.json b/web/composer.json
index ffa6101..4d62a2b 100644
--- a/web/composer.json
+++ b/web/composer.json
@@ -18,7 +18,8 @@
         "filp/whoops": "~2.0",
         "fzaninotto/faker": "~1.4",
         "mockery/mockery": "~1.0",
-        "phpunit/phpunit": "~7.0"
+        "phpunit/phpunit": "~7.0",
+        "squizlabs/php_codesniffer": "^3.4"
     },
     "autoload": {
         "classmap": [
diff --git a/web/composer.lock b/web/composer.lock
index a17deae..44e4e3f 100644
--- a/web/composer.lock
+++ b/web/composer.lock
@@ -4,7 +4,7 @@
         "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
         "This file is @generated automatically"
     ],
-    "content-hash": "11e073dc4b2a135a3794bc1adb56fcc0",
+    "content-hash": "f1609b1b7f62cab37a87f154e0277d43",
     "packages": [
         {
             "name": "composer/ca-bundle",
@@ -4816,6 +4816,57 @@
             "homepage": "https://github.com/sebastianbergmann/version",
             "time": "2016-10-03T07:35:21+00:00"
         },
+        {
+            "name": "squizlabs/php_codesniffer",
+            "version": "3.4.2",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/squizlabs/PHP_CodeSniffer.git",
+                "reference": "b8a7362af1cc1aadb5bd36c3defc4dda2cf5f0a8"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/b8a7362af1cc1aadb5bd36c3defc4dda2cf5f0a8",
+                "reference": "b8a7362af1cc1aadb5bd36c3defc4dda2cf5f0a8",
+                "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": "2019-04-10T23:49:02+00:00"
+        },
         {
             "name": "theseer/tokenizer",
             "version": "1.1.0",
diff --git a/web/phpcs.xml b/web/phpcs.xml
new file mode 100644
index 0000000..998c373
--- /dev/null
+++ b/web/phpcs.xml
@@ -0,0 +1,24 @@
+<?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>
+
diff --git a/web/routes/api.php b/web/routes/api.php
index b1ebcb6..ba8c41e 100644
--- a/web/routes/api.php
+++ b/web/routes/api.php
@@ -14,7 +14,7 @@ use App\Server;
 |
 */
 
-Route::post('record/{server}', function(Request $request, Server $server) {
+Route::post('record/{server}', function (Request $request, Server $server) {
     if ($server->token !== $request->get("token", "")) {
         abort(403);
     }
@@ -30,11 +30,11 @@ Route::post('record/{server}', function(Request $request, Server $server) {
 });
 
 Route::get(
-        'sensor/{server}/{token}/memory',
-        function(Server $server, string $token) {
-            if ($server->read_token != $token) {
-                abort(403);
-            }
+    'sensor/{server}/{token}/memory',
+    function (Server $server, string $token) {
+        if ($server->read_token != $token) {
+            abort(403);
+        }
 
             header('Access-Control-Allow-Origin: *');
             $meminfo = new App\Sensor\MemInfo($server);
@@ -42,30 +42,33 @@ Route::get(
                 "used" => $meminfo->usedMemoryPoints(),
                 "cached" => $meminfo->cachedMemoryPoints(),
                 "total" => $server->memoryTotal() / 1000];
-});
+    }
+);
 
 Route::get(
-        'sensor/{server}/{token}/load',
-        function(Server $server, string $token) {
-            if ($server->read_token != $token) {
-                abort(403);
-            }
+    'sensor/{server}/{token}/load',
+    function (Server $server, string $token) {
+        if ($server->read_token != $token) {
+            abort(403);
+        }
 
             header('Access-Control-Allow-Origin: *');
             $sensor = new App\Sensor\LoadAvg($server);
             return [
                 "points" => $sensor->loadPoints(),
                 "max" => $server->cpuinfo()["threads"]];
-});
+    }
+);
 
 Route::get(
-        'sensor/{server}/{token}/ifconfig',
-        function(Server $server, string $token) {
-            if ($server->read_token != $token) {
-                abort(403);
-            }
+    'sensor/{server}/{token}/ifconfig',
+    function (Server $server, string $token) {
+        if ($server->read_token != $token) {
+            abort(403);
+        }
 
             header('Access-Control-Allow-Origin: *');
             $sensor = new App\Sensor\Ifconfig($server);
             return $sensor->points();
-});
\ No newline at end of file
+    }
+);
diff --git a/web/routes/web.php b/web/routes/web.php
index baa43ea..64ad5de 100644
--- a/web/routes/web.php
+++ b/web/routes/web.php
@@ -17,26 +17,30 @@ Route::get('/', function () {
 
 Auth::routes(['register'=>false]);
 
-Route::get("home", function() {
+Route::get("home", function () {
     return redirect(action("OrganizationController@index"));
 });
 
-Route::get('app/dashboard', function() {
+Route::get('app/dashboard', function () {
     return redirect(action("OrganizationController@index"));
 })->name('dashboard');
 
 Route::get('app/organizations/{organization}/dashboard', 'OrganizationController@dashboard');
-Route::get('app/organizations/{organization}/reset-token',
-        'OrganizationController@resetToken');
-Route::get('app/organizations/{organization}/dashboard/{token}',
-        function(\App\Organization $organization, string $token) {
-
-    if ($organization->dashboard_token != $token) {
-        abort(403);
+Route::get(
+    'app/organizations/{organization}/reset-token',
+    'OrganizationController@resetToken'
+);
+Route::get(
+    'app/organizations/{organization}/dashboard/{token}',
+    function (\App\Organization $organization, string $token) {
+
+        if ($organization->dashboard_token != $token) {
+            abort(403);
+        }
+
+            return view("organization.dashboard", array("organization" => $organization));
     }
-
-    return view("organization.dashboard", array("organization" => $organization));
-})->name("organization.public.dashboard");
+)->name("organization.public.dashboard");
 Route::resource('app/organizations', 'OrganizationController');
 Route::resource("app/organizations.user", "OrganizationUserController");
-Route::resource('app/servers', 'ServerController');
\ No newline at end of file
+Route::resource('app/servers', 'ServerController');
diff --git a/web/tests/Feature/ExampleTest.php b/web/tests/Feature/ExampleTest.php
index d68b73a..1479e2e 100644
--- a/web/tests/Feature/ExampleTest.php
+++ b/web/tests/Feature/ExampleTest.php
@@ -38,7 +38,8 @@ class ExampleTest extends TestCase
         $data = [
             "token" => $server->token,
             "version" => "0.1.2",
-            "uname" => "Linux think 4.15.0-24-generic #26~16.04.1-Ubuntu SMP Fri Jun 15 14:35:08 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux",
+            "uname" => "Linux think 4.15.0-24-generic #26~16.04.1-Ubuntu SMP Fri Jun 15 14:35:08 UTC 2018"
+            . " x86_64 x86_64 x86_64 GNU/Linux",
             "loadavg" => "0.83 0.87 0.70 2/1747 25404",
             "reboot" => true,
             "updates" => "
diff --git a/web/tests/Unit/ExampleTest.php b/web/tests/Unit/ExampleTest.php
index d677d69..0921fc8 100644
--- a/web/tests/Unit/ExampleTest.php
+++ b/web/tests/Unit/ExampleTest.php
@@ -25,7 +25,8 @@ class ExampleTest extends TestCase
         $this->assertTrue(true);
     }
 
-    public function testRelations() {
+    public function testRelations()
+    {
         $user = new User();
         $user->name = "test";
         $user->email = "test@example.com";
@@ -38,14 +39,18 @@ class ExampleTest extends TestCase
 
         $organization->users()->save($user);
 
-        $this->assertEquals("Org", $user->organizations()->first()->name);
+        $this->assertEquals(
+            "Org",
+            $user->organizations()->first()->name
+        );
     }
 
     /**
      * @group ifconfig
      * @group sensors
      */
-    public function testIfconfig() {
+    public function testIfconfig()
+    {
         $string = file_get_contents(__DIR__ . "/ifconfig");
         $sensor = new Ifconfig(new \App\Server());
         $interfaces = $sensor->parseIfconfig($string);
@@ -54,10 +59,10 @@ class ExampleTest extends TestCase
         $this->assertEquals("10.67.1.32", $interfaces[1]->address);
         $this->assertEquals(1074590056, $interfaces[1]->rx);
         $this->assertEquals(2074977132, $interfaces[1]->tx);
-
     }
 
-    public function testDisksSensor() {
+    public function testDisksSensor()
+    {
         $string = file_get_contents(__DIR__ . "/df");
         $sensor = new Disks(new \App\Server());
         $disks = $sensor->parse($string);
@@ -66,14 +71,16 @@ class ExampleTest extends TestCase
         $this->assertEquals(1128926648, $disks[1]->blocks);
     }
 
-    public function testSsacli() {
+    public function testSsacli()
+    {
         $string = file_get_contents(__DIR__ . "/ssacli");
         $sensor = new \App\Sensor\Ssacli(new \App\Server());
         $disks = $sensor->parse($string);
         $this->assertEquals("OK", $disks[0]->status);
     }
 
-    public function testUpdates() {
+    public function testUpdates()
+    {
         $string = "6 packages can be updated.
 2 updates are security updates.";
 
@@ -82,7 +89,8 @@ class ExampleTest extends TestCase
         $this->assertEquals(2, $status["security"]);
     }
 
-    public function testMeminfo() {
+    public function testMeminfo()
+    {
         $string = file_get_contents(__DIR__ . "/meminfo");
         $server = new \App\Server();
         $mem_total = $server->parseMeminfo($string);
@@ -92,7 +100,8 @@ class ExampleTest extends TestCase
     /**
      * @group cpuinfo
      */
-    public function testCpuinfo() {
+    public function testCpuinfo()
+    {
         $string = file_get_contents(__DIR__ . "/cpuinfo");
         $server = new \App\Server();
         $cpuinfo = $server->parseCpuinfo($string);
@@ -103,7 +112,8 @@ class ExampleTest extends TestCase
     /**
      * @group cpuinfo
      */
-    public function testCpuinfoSingleCPU() {
+    public function testCpuinfoSingleCPU()
+    {
         $string = file_get_contents(__DIR__ . "/cpuinfo_1cpu");
         $server = new \App\Server();
         $cpuinfo = $server->parseCpuinfo($string);
@@ -111,21 +121,24 @@ class ExampleTest extends TestCase
         $this->assertEquals("Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz", $cpuinfo["cpu"]);
     }
 
-    public function testManufacturer() {
+    public function testManufacturer()
+    {
         $string = file_get_contents(__DIR__ . "/system");
         $server = new \App\Server();
         $manufacturer = $server->parseManufacturer($string);
         $this->assertEquals("LENOVO", $manufacturer);
     }
 
-    public function testProductName() {
+    public function testProductName()
+    {
         $string = file_get_contents(__DIR__ . "/system");
         $server = new \App\Server();
         $manufacturer = $server->parseProductName($string);
         $this->assertEquals("20J60018MB", $manufacturer);
     }
 
-    public function testClientVersion() {
+    public function testClientVersion()
+    {
         $server = new \App\Server();
         $client_version = new \App\Sensor\ClientVersion($server);
         $this->assertStringMatchesFormat('%f', $client_version->latestVersion());
@@ -134,7 +147,8 @@ class ExampleTest extends TestCase
     /**
      * @group status-change
      */
-    public function testStatusChangeDetection() {
+    public function testStatusChangeDetection()
+    {
         $organization = new Organization();
         $organization->name = "ACME";
         $organization->save();
@@ -168,8 +182,8 @@ class ExampleTest extends TestCase
         // Check if a new StatusChange was inserted in Mongo
         $last_change = \App\StatusChange::getLastChangeForServer($server_id);
         $this->assertEquals(
-                $server->status(),
-                $last_change->status);
-
+            $server->status(),
+            $last_change->status
+        );
     }
 }
-- 
GitLab