Skip to content

Commit

Permalink
Applied fixes from StyleCI (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
irazasyed committed May 4, 2016
1 parent b8c0512 commit c7a8781
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 44 deletions.
40 changes: 23 additions & 17 deletions src/Console/VendorPublishCommand.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<?php
<?php

namespace Irazasyed\Larasupport\Console;

use Illuminate\Console\Command;
use League\Flysystem\MountManager;
use Illuminate\Filesystem\Filesystem;
use Illuminate\Support\ServiceProvider;
use League\Flysystem\Filesystem as Flysystem;
use League\Flysystem\Adapter\Local as LocalAdapter;
use League\Flysystem\Filesystem as Flysystem;
use League\Flysystem\MountManager;

class VendorPublishCommand extends Command
{
Expand Down Expand Up @@ -37,7 +37,8 @@ class VendorPublishCommand extends Command
/**
* Create a new command instance.
*
* @param \Illuminate\Filesystem\Filesystem $files
* @param \Illuminate\Filesystem\Filesystem $files
*
* @return void
*/
public function __construct(Filesystem $files)
Expand Down Expand Up @@ -66,7 +67,8 @@ public function fire()
/**
* Publishes the assets for a tag.
*
* @param string $tag
* @param string $tag
*
* @return mixed
*/
private function publishTag($tag)
Expand Down Expand Up @@ -95,13 +97,14 @@ private function publishTag($tag)
/**
* Publish the file to the given path.
*
* @param string $from
* @param string $to
* @param string $from
* @param string $to
*
* @return void
*/
protected function publishFile($from, $to)
{
if ($this->files->exists($to) && ! $this->option('force')) {
if ($this->files->exists($to) && !$this->option('force')) {
return;
}

Expand All @@ -115,19 +118,20 @@ protected function publishFile($from, $to)
/**
* Publish the directory to the given directory.
*
* @param string $from
* @param string $to
* @param string $from
* @param string $to
*
* @return void
*/
protected function publishDirectory($from, $to)
{
$manager = new MountManager([
'from' => new Flysystem(new LocalAdapter($from)),
'to' => new Flysystem(new LocalAdapter($to)),
'to' => new Flysystem(new LocalAdapter($to)),
]);

foreach ($manager->listContents('from://', true) as $file) {
if ($file['type'] === 'file' && (! $manager->has('to://'.$file['path']) || $this->option('force'))) {
if ($file['type'] === 'file' && (!$manager->has('to://'.$file['path']) || $this->option('force'))) {
$manager->put('to://'.$file['path'], $manager->read('from://'.$file['path']));
}
}
Expand All @@ -138,22 +142,24 @@ protected function publishDirectory($from, $to)
/**
* Create the directory to house the published files if needed.
*
* @param string $directory
* @param string $directory
*
* @return void
*/
protected function createParentDirectory($directory)
{
if (! $this->files->isDirectory($directory)) {
if (!$this->files->isDirectory($directory)) {
$this->files->makeDirectory($directory, 0755, true);
}
}

/**
* Write a status message to the console.
*
* @param string $from
* @param string $to
* @param string $type
* @param string $from
* @param string $to
* @param string $type
*
* @return void
*/
protected function status($from, $to, $type)
Expand Down
14 changes: 7 additions & 7 deletions src/Providers/ArtisanServiceProvider.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
<?php namespace Irazasyed\Larasupport\Providers;
<?php

namespace Irazasyed\Larasupport\Providers;

use Illuminate\Support\ServiceProvider;
use Irazasyed\Larasupport\Console\VendorPublishCommand;

class ArtisanServiceProvider extends ServiceProvider {

class ArtisanServiceProvider extends ServiceProvider
{
/**
* Indicates if loading of the provider is deferred.
*
Expand All @@ -31,8 +33,7 @@ public function register()
*/
protected function registerVendorPublishCommand()
{
$this->app->singleton('command.vendor.publish', function($app)
{
$this->app->singleton('command.vendor.publish', function ($app) {
return new VendorPublishCommand($app['files']);
});
}
Expand All @@ -46,5 +47,4 @@ public function provides()
{
return ['command.vendor.publish'];
}

}
}
38 changes: 18 additions & 20 deletions src/helpers.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<?php

if ( ! function_exists('route_parameter'))
{
if (!function_exists('route_parameter')) {
/**
* Get a given parameter from the route.
*
Expand All @@ -18,12 +17,12 @@ function route_parameter($name, $default = null)
}
}

if ( ! function_exists('database_path'))
{
if (!function_exists('database_path')) {
/**
* Get the database path.
*
* @param string $path
* @param string $path
*
* @return string
*/
function database_path($path = '')
Expand All @@ -32,12 +31,12 @@ function database_path($path = '')
}
}

if ( ! function_exists('config_path'))
{
if (!function_exists('config_path')) {
/**
* Get the configuration path.
*
* @param string $path
* @param string $path
*
* @return string
*/
function config_path($path = '')
Expand All @@ -46,12 +45,12 @@ function config_path($path = '')
}
}

if ( ! function_exists('public_path'))
{
if (!function_exists('public_path')) {
/**
* Get the path to the public folder.
*
* @param string $path
* @param string $path
*
* @return string
*/
function public_path($path = '')
Expand All @@ -60,31 +59,30 @@ function public_path($path = '')
}
}

if (! function_exists('elixir'))
{
if (!function_exists('elixir')) {
/**
* Get the path to a versioned Elixir file.
*
* @param string $file
*
* @return string
* @param string $file
*
* @throws \InvalidArgumentException
*
* @return string
*/
function elixir($file)
{
static $manifest = null;

$buildPath = trim(env('ELIXIR_BUILD_PATH', 'build'), '/'); // Trim start & end slashes.

if (is_null($manifest)) {
$manifest = json_decode(file_get_contents(public_path($buildPath.'/rev-manifest.json')), true);
}

if (isset($manifest[$file])) {
return '/'.$buildPath.'/'.$manifest[$file];
}

throw new InvalidArgumentException("File {$file} not defined in asset manifest.");
}
}

0 comments on commit c7a8781

Please sign in to comment.