Skip to content

Commit

Permalink
Merge branch 'master' of github.com:Dumkaaa/BxOptimize
Browse files Browse the repository at this point in the history
  • Loading branch information
Dumkaaa committed Apr 4, 2017
2 parents 536d14e + 40a38c1 commit 32338eb
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 23 deletions.
2 changes: 1 addition & 1 deletion lib/Cli/SymfonyOptimize.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ protected function execute(InputInterface $input, OutputInterface $output)

$output->writeln('<info>BxOptimization set up.</info>');
} catch (\Exception $e) {
$output->writeln('<error>'.get_class($e).': '.$e->getMessage().'</error>');
$output->writeln('<error>' . get_class($e) . ': ' . $e->getMessage() . '</error>');
}
}
}
2 changes: 1 addition & 1 deletion lib/Finder/FilesFinder.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class FilesFinder implements FinderInterface
public function __construct($path)
{
$basePath = $_SERVER['DOCUMENT_ROOT'];
$path = $basePath .'/'. trim($path, '\/');
$path = $basePath . '/' . trim($path, '\/');
if (empty($path) || !(is_dir($path) || is_file($path)) || !is_writable($path)) {
throw new Exception('Путь не может быть пустым или нет доступа');
}
Expand Down
2 changes: 1 addition & 1 deletion lib/Handler/CssHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class CssHandler extends Handler
public function handleQueue()
{
foreach ($this->files as $file) {
echo get_class()." обрабатывает файл: $file\n";
echo get_class() . " обрабатывает файл: $file\n";
}
// TODO: Implement handleQueue() method.
}
Expand Down
4 changes: 2 additions & 2 deletions lib/Handler/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ abstract class Handler implements HandlerInterface
public function canHandleFile($file = null)
{
if (is_null($file)) {
throw new \Exception('В обработчик '.get_class()." передано неверное имя файла: $file");
throw new \Exception('В обработчик ' . get_class() . " передано неверное имя файла: $file");
}

$ext = strtolower(pathinfo($file, PATHINFO_EXTENSION));
Expand All @@ -38,7 +38,7 @@ public function queueFile($file)
public function handleQueue()
{
foreach ($this->files as $file) {
echo get_class()." обрабатывает файл: $file\n";
echo get_class() . " обрабатывает файл: $file\n";
}
// TODO: Implement handleQueue() method.
}
Expand Down
16 changes: 8 additions & 8 deletions lib/Handler/HandlerInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ interface HandlerInterface
*/
public function canHandleFile($file);

/**
* Записывает файл в очередь на обработку.
*
* @param string $file Путь к файлу
*
* @return void
*/
public function queueFile($file);
/**
* Записывает файл в очередь на обработку.
*
* @param string $file Путь к файлу
*
* @return void
*/
public function queueFile($file);

/**
* Обрабатывает файлы в очереди.
Expand Down
4 changes: 2 additions & 2 deletions lib/Handler/HandlerTools.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class HandlerTools
],
];

public static function getBinaryHandler($type){
public static function getBinaryHandler($type) {

$handlers = self::getBinaryHandlers();

Expand All @@ -59,7 +59,7 @@ public static function getBinaryHandler($type){

}

public static function getBinaryHandlers(){
public static function getBinaryHandlers() {

$os = strtolower(PHP_OS);
if (substr($os, 0, 3) == "win") {
Expand Down
6 changes: 3 additions & 3 deletions lib/Handler/ImageHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,20 @@ public function handleQueue()

$ext = strtolower(pathinfo($file, PATHINFO_EXTENSION));

if($handlers[$ext]) {
if ($handlers[$ext]) {

switch ($ext) {
case 'png':
$command = sprintf($this->args[$ext], escapeshellarg($file));
break;
case 'jpg':
case 'jpeg':
$command = sprintf($this->args[$ext], escapeshellarg($file), escapeshellarg($file . ".original"));
$command = sprintf($this->args[$ext], escapeshellarg($file), escapeshellarg($file . ".original"));
break;
}
if (!file_exists($file . ".original") && $command) {
copy($file, $file . ".original");
exec($handlers[$ext] . $command);
exec($handlers[$ext] . $command);
}

} else {
Expand Down
10 changes: 5 additions & 5 deletions lib/Install/Installer.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class Installer
*/
public static function getBinaries(Event $event)
{
$dir = self::getRootPath().'/bin';
$dir = self::getRootPath() . '/bin';

if (!file_exists($dir)) {
mkdir($dir);
Expand All @@ -36,11 +36,11 @@ public static function getBinaries(Event $event)
foreach (self::$extByPlatforms as $ext) {
foreach (self::$tools as $tool) {
file_put_contents(
$dir.'/'.$tool.$ext,
fopen('https://github.com/nosilver4u/ewww-image-optimizer/raw/master/binaries/'.$tool.$ext, 'r')
$dir . '/' . $tool . $ext,
fopen('https://github.com/nosilver4u/ewww-image-optimizer/raw/master/binaries/' . $tool . $ext, 'r')
);
chmod($dir.'/'.$tool.$ext, 0754);
$event->getIO()->write($tool.$ext);
chmod($dir . '/' . $tool . $ext, 0754);
$event->getIO()->write($tool . $ext);
}
}

Expand Down

0 comments on commit 32338eb

Please sign in to comment.