From 667767da443a55f80673bcbe8fcaad443a51415d Mon Sep 17 00:00:00 2001
From: jurgenhaas <juergen@paragon-es.de>
Date: Sun, 5 Nov 2017 12:15:28 +0100
Subject: [PATCH] Change to a library and ensure coding standard.

---
 src/Traefik.php => Traefik.php | 27 +++++++++++++++++----------
 composer.json                  | 23 ++++++++++++++---------
 phpunit.xml.dist               | 15 ---------------
 tests/TraefikTest.php          | 28 ----------------------------
 4 files changed, 31 insertions(+), 62 deletions(-)
 rename src/Traefik.php => Traefik.php (81%)
 delete mode 100644 phpunit.xml.dist
 delete mode 100644 tests/TraefikTest.php

diff --git a/src/Traefik.php b/Traefik.php
similarity index 81%
rename from src/Traefik.php
rename to Traefik.php
index 88033f4..072844f 100644
--- a/src/Traefik.php
+++ b/Traefik.php
@@ -5,39 +5,46 @@ namespace LakeDrops\DockerTraefik;
 use Symfony\Component\Filesystem\Filesystem;
 use Symfony\Component\Yaml\Yaml;
 
+/**
+ * Class Traefik.
+ *
+ * @package LakeDrops\DockerTraefik
+ */
 class Traefik {
 
-  /** @var string */
+  /**
+   * The name of the project using Traefik.
+   *
+   * @var string
+   */
   protected $name;
 
-  /** @var Filesystem */
-  protected $fs;
-
   /**
    * Traefik constructor.
    *
    * @param string $name
-   *  Name of the network to be created which needs to match the container
-   *  prefix of your project you would like to handle with Traefik.
+   *   Name of the network to be created which needs to match the container
+   *   prefix of your project you would like to handle with Traefik.
    */
   public function __construct($name) {
     $this->name = $name;
-    $this->fs = new Filesystem();
   }
 
   /**
    * Update the Traefik container.
    */
   public function update() {
-    // Update host wider traefik container
+    // Update host wider traefik container.
     $traefikPath = $_SERVER['HOME'] . '/.traefik';
     $traefikFile = $traefikPath . '/docker-compose.yml';
 
-    if ($this->fs->exists($traefikFile)) {
+    /* @var FileSystem $fs */
+    $fs = new Filesystem();
+    if ($fs->exists($traefikFile)) {
       $traefik = Yaml::parse(file_get_contents($traefikFile));
     }
     else {
-      $this->fs->mkdir($traefikPath);
+      $fs->mkdir($traefikPath);
       $traefik = [
         'version' => '2',
         'services' => [
diff --git a/composer.json b/composer.json
index 8d2b827..77652f8 100644
--- a/composer.json
+++ b/composer.json
@@ -3,7 +3,7 @@
     "description": "Library to prepare local Traefik Docker container which is used by e.g. Docker4Drupal.",
     "type": "library",
     "keywords": ["Drupal", "Development", "Docker"],
-    "homepage": "https://gitlab.lakedrops.com/composer/plugin/docker-traefik",
+    "homepage": "https://gitlab.lakedrops.com/composer/library/docker-traefik",
     "license": "GPL-2.0+",
     "authors": [
         {
@@ -20,20 +20,25 @@
         }
     ],
     "support": {
-        "issues": "https://gitlab.lakedrops.com/composer/plugin/docker-traefik/issues",
-        "source": "https://gitlab.lakedrops.com/composer/plugin/docker-traefik/tree/master"
+        "issues": "https://gitlab.lakedrops.com/composer/library/docker-traefik/issues",
+        "source": "https://gitlab.lakedrops.com/composer/library/docker-traefik/tree/master"
     },
     "require": {
         "php": ">=5.6",
-        "symfony/filesystem": "^2",
-        "symfony/yaml": "^2"
+        "symfony/filesystem": "^3",
+        "symfony/yaml": "^3"
     },
+    "require-dev": {
+        "composer/composer": "^1.5.0",
+        "dealerdirect/phpcodesniffer-composer-installer": "^0.4.3",
+        "drupal/coder": "^8.2",
+        "phpunit/phpunit": "^4.8.0"
+    },
+    "minimum-stability": "dev",
+    "prefer-stable": true,
     "autoload": {
         "psr-4": {
-            "LakeDrops\\DockerTraefik\\": "src/"
+            "LakeDrops\\DockerTraefik\\": ""
         }
-    },
-    "require-dev": {
-        "phpunit/phpunit": "^4.4.0"
     }
 }
diff --git a/phpunit.xml.dist b/phpunit.xml.dist
deleted file mode 100644
index 03b6e5f..0000000
--- a/phpunit.xml.dist
+++ /dev/null
@@ -1,15 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-    xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.1/phpunit.xsd"
-    backupGlobals="false"
-    colors="true"
-    bootstrap="vendor/autoload.php"
-    verbose="true"
->
-    <testsuites>
-        <testsuite name="docker-traefik">
-            <directory>./tests/</directory>
-        </testsuite>
-    </testsuites>
-</phpunit>
diff --git a/tests/TraefikTest.php b/tests/TraefikTest.php
deleted file mode 100644
index 3be9c0d..0000000
--- a/tests/TraefikTest.php
+++ /dev/null
@@ -1,28 +0,0 @@
-<?php
-
-/**
- * @file
- * Contains \LakeDrops\DockerTraefik\Tests\TraefikTest.
- */
-
-namespace LakeDrops\DockerTraefik\Tests;
-
-use LakeDrops\DockerTraefik\Traefik;
-use PHPUnit\Framework\TestCase;
-
-/**
- * Tests composer library functionality.
- */
-class TraefikTest extends TestCase {
-
-  static $name = 'docker-traefik';
-
-  /**
-   * Test if we can initialize the main class.
-   */
-  public function testComposerInstallAndUpdate() {
-    $traefik = new Traefik('test');
-    $this->assertInstanceOf('LakeDrops\DockerTraefik\Traefik', $traefik);
-  }
-
-}
-- 
GitLab