From 7d6cfe8e506c6214ba8ee2f94487f5646506b6ee Mon Sep 17 00:00:00 2001
From: jurgenhaas <juergen@paragon-es.de>
Date: Sun, 5 Nov 2017 12:44:08 +0100
Subject: [PATCH] Coding standard

---
 composer.json   | 12 ++++++++----
 src/Handler.php | 46 ++++++++++++++++++++++++++++++++++------------
 src/Plugin.php  |  9 +++++++--
 3 files changed, 49 insertions(+), 18 deletions(-)

diff --git a/composer.json b/composer.json
index 90c8bb5..f90fc92 100644
--- a/composer.json
+++ b/composer.json
@@ -29,6 +29,14 @@
         "lakedrops/dotenv": "^0.1",
         "php": ">=5.6"
     },
+    "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\\DorgFlow\\": "src/"
@@ -36,9 +44,5 @@
     },
     "extra": {
         "class": "LakeDrops\\DorgFlow\\Plugin"
-    },
-    "require-dev": {
-        "composer/composer": "dev-master",
-        "phpunit/phpunit": "^4.4.0"
     }
 }
diff --git a/src/Handler.php b/src/Handler.php
index d5c159a..088464c 100644
--- a/src/Handler.php
+++ b/src/Handler.php
@@ -2,22 +2,30 @@
 
 namespace LakeDrops\DorgFlow;
 
-use Composer\Package\PackageInterface;
 use Composer\Composer;
 use Composer\IO\IOInterface;
-use Composer\Script\Event as ScriptEvent;
+use Composer\Script\Event;
 use GitElephant\Repository;
 use LakeDrops\Component\Dotenv\Dotenv;
 use Symfony\Component\Filesystem\Filesystem;
 
+/**
+ * Class Handler.
+ *
+ * @package LakeDrops\DorgFlow
+ */
 class Handler {
 
   /**
+   * The composer object of this session.
+   *
    * @var \Composer\Composer
    */
   protected $composer;
 
   /**
+   * The input-output object of the composer session.
+   *
    * @var \Composer\IO\IOInterface
    */
   protected $io;
@@ -25,8 +33,10 @@ class Handler {
   /**
    * Handler constructor.
    *
-   * @param Composer $composer
-   * @param IOInterface $io
+   * @param \Composer\Composer $composer
+   *   The composer object of this session.
+   * @param \Composer\IO\IOInterface $io
+   *   The input-output object of the composer session.
    */
   public function __construct(Composer $composer, IOInterface $io) {
     $this->composer = $composer;
@@ -39,7 +49,8 @@ class Handler {
    * @param string $name
    *   Name of the package to get from the current composer installation.
    *
-   * @return PackageInterface
+   * @return \Composer\Package\PackageInterface
+   *   The package.
    */
   protected function getPackage($name) {
     return $this->composer->getRepositoryManager()->getLocalRepository()->findPackage($name, '*');
@@ -48,11 +59,12 @@ class Handler {
   /**
    * Post install/update event to prepare projects for development.
    *
-   * @param ScriptEvent $event
+   * @param \Composer\Script\Event $event
+   *   The event that triggered the call of this function.
    */
-  public function prepareDevProjects($event) {
+  public function prepareDevProjects(Event $event) {
 
-    // We only do the fancy stuff for developers
+    // We only do the fancy stuff for developers.
     if (!$event->isDevMode()) {
       return;
     }
@@ -77,9 +89,10 @@ class Handler {
   }
 
   /**
-   * Retrieve excludes from optional "extra" configuration.
+   * Retrieve options from composer.json "extra" configuration.
    *
    * @return array
+   *   The options.
    */
   protected function getOptions() {
     $env = new Dotenv('dorgflow', $this->io);
@@ -92,13 +105,22 @@ class Handler {
   }
 
   /**
-   * @inheritDoc
+   * Prepare the working directory of a git based package for dorgflow.
+   *
+   * @param string $path
+   *   Name of the working directory.
+   * @param string $project
+   *   Name of the project.
+   * @param string $version
+   *   Version to checkout.
+   * @param string $username
+   *   Username on drupal.org.
    */
   protected function prepareWorkingDirectory($path, $project, $version, $username) {
     list(, $projectname) = explode('/', $project);
     $uri = $username . '@git.drupal.org:project/' . $projectname . '.git';
 
-    // Git Clone the repository into the working directory
+    // Git Clone the repository into the working directory.
     $repository = Repository::open($path);
     $repository->init();
 
@@ -110,7 +132,7 @@ class Handler {
       }
     }
     catch (\Exception $ex) {
-      // ignore the exception and conitue setup.
+      // Ignore the exception and conitue setup.
     }
 
     $fs = new Filesystem();
diff --git a/src/Plugin.php b/src/Plugin.php
index cb64a27..56be748 100644
--- a/src/Plugin.php
+++ b/src/Plugin.php
@@ -6,6 +6,7 @@ use Composer\Composer;
 use Composer\EventDispatcher\EventSubscriberInterface;
 use Composer\IO\IOInterface;
 use Composer\Plugin\PluginInterface;
+use Composer\Script\Event;
 use Composer\Script\ScriptEvents;
 
 /**
@@ -14,6 +15,8 @@ use Composer\Script\ScriptEvents;
 class Plugin implements PluginInterface, EventSubscriberInterface {
 
   /**
+   * The handler object to configure the project for dorgflow.
+   *
    * @var \LakeDrops\DorgFlow\Handler
    */
   protected $handler;
@@ -39,8 +42,9 @@ class Plugin implements PluginInterface, EventSubscriberInterface {
    * Post install/update event callback.
    *
    * @param \Composer\Script\Event $event
+   *   The event that triggered the call of this function.
    */
-  public function prepareDevProjects($event) {
+  public function prepareDevProjects(Event $event) {
     $this->handler->prepareDevProjects($event);
   }
 
@@ -48,8 +52,9 @@ class Plugin implements PluginInterface, EventSubscriberInterface {
    * Script callback for putting in composer scripts to prepare the project.
    *
    * @param \Composer\Script\Event $event
+   *   The event that triggered the call of this function.
    */
-  public static function prepare($event) {
+  public static function prepare(Event $event) {
     $handler = new Handler($event->getComposer(), $event->getIO());
     $handler->prepareDevProjects($event);
   }
-- 
GitLab