mirror of
https://github.com/hauke68/Magallanes.git
synced 2025-09-13 12:40:18 +02:00
PHPStorm refactoring.
This commit is contained in:
parent
4c584b2634
commit
fddeebe59a
@ -30,8 +30,7 @@ class Autoload
|
|||||||
//Try to load a normal Mage class (or Task). Think that Mage component is compiled to .phar
|
//Try to load a normal Mage class (or Task). Think that Mage component is compiled to .phar
|
||||||
$baseDir = dirname(dirname(__FILE__));
|
$baseDir = dirname(dirname(__FILE__));
|
||||||
$classFileWithinPhar = $baseDir . $postfix;
|
$classFileWithinPhar = $baseDir . $postfix;
|
||||||
if($this->isReadable($classFileWithinPhar))
|
if ($this->isReadable($classFileWithinPhar)) {
|
||||||
{
|
|
||||||
/** @noinspection PhpIncludeInspection */
|
/** @noinspection PhpIncludeInspection */
|
||||||
require_once $classFileWithinPhar;
|
require_once $classFileWithinPhar;
|
||||||
return true;
|
return true;
|
||||||
|
@ -55,7 +55,8 @@ class InstallCommand extends AbstractCommand
|
|||||||
|
|
||||||
// Check if there is already a symlink
|
// Check if there is already a symlink
|
||||||
if (file_exists($destinationDir . '/' . 'latest')
|
if (file_exists($destinationDir . '/' . 'latest')
|
||||||
&& is_link($destinationDir . '/' . 'latest')) {
|
&& is_link($destinationDir . '/' . 'latest')
|
||||||
|
) {
|
||||||
unlink($destinationDir . '/' . 'latest');
|
unlink($destinationDir . '/' . 'latest');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -116,7 +116,8 @@ class Config
|
|||||||
* @return array
|
* @return array
|
||||||
* @throws Config\ConfigNotFoundException
|
* @throws Config\ConfigNotFoundException
|
||||||
*/
|
*/
|
||||||
protected function loadGeneral($filePath){
|
protected function loadGeneral($filePath)
|
||||||
|
{
|
||||||
return $this->parseConfigFile($filePath);
|
return $this->parseConfigFile($filePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -142,6 +143,7 @@ class Config
|
|||||||
|
|
||||||
return $settings;
|
return $settings;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads the Environment configuration
|
* Loads the Environment configuration
|
||||||
* @param $filePath string
|
* @param $filePath string
|
||||||
@ -171,8 +173,7 @@ class Config
|
|||||||
{
|
{
|
||||||
$environment = $this->getEnvironment();
|
$environment = $this->getEnvironment();
|
||||||
|
|
||||||
if(!empty($environment))
|
if (!empty($environment)) {
|
||||||
{
|
|
||||||
$configFilePath = getcwd() . '/.mage/config/environment/' . $environment . '.yml';
|
$configFilePath = getcwd() . '/.mage/config/environment/' . $environment . '.yml';
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -193,16 +194,15 @@ class Config
|
|||||||
{
|
{
|
||||||
if (empty($parameters))
|
if (empty($parameters))
|
||||||
return true;
|
return true;
|
||||||
foreach($parameters as $parameter)
|
foreach ($parameters as $parameter) {
|
||||||
{
|
if (isset(Console::$paramsNotRequiringEnvironment[$parameter])) {
|
||||||
if(isset(Console::$paramsNotRequiringEnvironment[$parameter]))
|
|
||||||
{
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load the Configuration and parses the Arguments
|
* Load the Configuration and parses the Arguments
|
||||||
*
|
*
|
||||||
@ -575,13 +575,13 @@ class Config
|
|||||||
*/
|
*/
|
||||||
public function parseConfigFile($filePath)
|
public function parseConfigFile($filePath)
|
||||||
{
|
{
|
||||||
if(!file_exists($filePath))
|
if (!file_exists($filePath)) {
|
||||||
{
|
|
||||||
throw new ConfigNotFoundException("Cannot find the file at path $filePath");
|
throw new ConfigNotFoundException("Cannot find the file at path $filePath");
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->parseConfigText(file_get_contents($filePath));
|
return $this->parseConfigText(file_get_contents($filePath));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function parseConfigText($input)
|
public function parseConfigText($input)
|
||||||
{
|
{
|
||||||
return Yaml::parse($input);
|
return Yaml::parse($input);
|
||||||
|
@ -66,8 +66,7 @@ class Mailer
|
|||||||
array('{project}', '{environment}', '{result}'),
|
array('{project}', '{environment}', '{result}'),
|
||||||
array($this->project, $this->environment, $result ? 'SUCCESS' : 'FAILURE'),
|
array($this->project, $this->environment, $result ? 'SUCCESS' : 'FAILURE'),
|
||||||
self::SUBJECT
|
self::SUBJECT
|
||||||
)
|
);
|
||||||
;
|
|
||||||
$attachment = chunk_split(base64_encode(file_get_contents($this->logFile)));
|
$attachment = chunk_split(base64_encode(file_get_contents($this->logFile)));
|
||||||
|
|
||||||
$message = 'This is a multi-part message in MIME format.' . self::EOL
|
$message = 'This is a multi-part message in MIME format.' . self::EOL
|
||||||
@ -83,8 +82,7 @@ class Mailer
|
|||||||
. 'Content-Disposition: attachment' . self::EOL
|
. 'Content-Disposition: attachment' . self::EOL
|
||||||
. self::EOL
|
. self::EOL
|
||||||
. $attachment . self::EOL
|
. $attachment . self::EOL
|
||||||
. '--Mage-mixed-' . $boundary . '--' . self::EOL
|
. '--Mage-mixed-' . $boundary . '--' . self::EOL;
|
||||||
;
|
|
||||||
|
|
||||||
@mail($this->address, $subject, $message, $headers);
|
@mail($this->address, $subject, $message, $headers);
|
||||||
}
|
}
|
||||||
|
@ -171,7 +171,8 @@ class EncryptTask extends AbstractTask
|
|||||||
*
|
*
|
||||||
* @see \Mage\Task\AbstractTask::getName()
|
* @see \Mage\Task\AbstractTask::getName()
|
||||||
*/
|
*/
|
||||||
public function getName() {
|
public function getName()
|
||||||
|
{
|
||||||
return $this->name;
|
return $this->name;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -180,7 +181,8 @@ class EncryptTask extends AbstractTask
|
|||||||
*
|
*
|
||||||
* @see \Mage\Task\AbstractTask::init()
|
* @see \Mage\Task\AbstractTask::init()
|
||||||
*/
|
*/
|
||||||
public function init() {
|
public function init()
|
||||||
|
{
|
||||||
// Set the default extensions to ignore
|
// Set the default extensions to ignore
|
||||||
$this->checkIgnoreExtens = array(
|
$this->checkIgnoreExtens = array(
|
||||||
'jpg',
|
'jpg',
|
||||||
@ -324,7 +326,8 @@ class EncryptTask extends AbstractTask
|
|||||||
* @return bool
|
* @return bool
|
||||||
* @throws \Mage\Task\ErrorWithMessageException
|
* @throws \Mage\Task\ErrorWithMessageException
|
||||||
*/
|
*/
|
||||||
public function run() {
|
public function run()
|
||||||
|
{
|
||||||
$this->switchSrcToTmp();
|
$this->switchSrcToTmp();
|
||||||
$this->writeProjectFile();
|
$this->writeProjectFile();
|
||||||
$result = $this->runIonCube();
|
$result = $this->runIonCube();
|
||||||
@ -351,7 +354,8 @@ class EncryptTask extends AbstractTask
|
|||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
private function checkEncoding() {
|
private function checkEncoding()
|
||||||
|
{
|
||||||
$src = $this->source;
|
$src = $this->source;
|
||||||
// $ask holds flag to indicate we need to prompt the end user
|
// $ask holds flag to indicate we need to prompt the end user
|
||||||
$ask = false;
|
$ask = false;
|
||||||
@ -407,7 +411,8 @@ class EncryptTask extends AbstractTask
|
|||||||
*
|
*
|
||||||
* @return bool True if 'y' pressed
|
* @return bool True if 'y' pressed
|
||||||
*/
|
*/
|
||||||
private function promptYn() {
|
private function promptYn()
|
||||||
|
{
|
||||||
$handle = fopen("php://stdin", "r");
|
$handle = fopen("php://stdin", "r");
|
||||||
$line = strtolower(fgets($handle));
|
$line = strtolower(fgets($handle));
|
||||||
if (trim($line) != 'y') {
|
if (trim($line) != 'y') {
|
||||||
@ -428,7 +433,8 @@ class EncryptTask extends AbstractTask
|
|||||||
*
|
*
|
||||||
* @return boolean True if file was encoded/encrypted
|
* @return boolean True if file was encoded/encrypted
|
||||||
*/
|
*/
|
||||||
private function checkFileCoding($filename) {
|
private function checkFileCoding($filename)
|
||||||
|
{
|
||||||
// check to see if this is an encrypted file
|
// check to see if this is an encrypted file
|
||||||
$ioncube = ioncube_read_file($filename, $ioncubeType);
|
$ioncube = ioncube_read_file($filename, $ioncubeType);
|
||||||
if (is_int($ioncube)) {
|
if (is_int($ioncube)) {
|
||||||
@ -461,7 +467,8 @@ class EncryptTask extends AbstractTask
|
|||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
private function deleteTmpFiles() {
|
private function deleteTmpFiles()
|
||||||
|
{
|
||||||
if (isset ($this->mageConfig ['keeptemp'])) {
|
if (isset ($this->mageConfig ['keeptemp'])) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -480,7 +487,8 @@ class EncryptTask extends AbstractTask
|
|||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
private function runIonCube() {
|
private function runIonCube()
|
||||||
|
{
|
||||||
$cli = $this->encoder . ' --project-file ' . $this->projectFile . ' ' . $this->ionSource . DIRECTORY_SEPARATOR . '*';
|
$cli = $this->encoder . ' --project-file ' . $this->projectFile . ' ' . $this->ionSource . DIRECTORY_SEPARATOR . '*';
|
||||||
$ret = Console::executeCommand($cli, $out);
|
$ret = Console::executeCommand($cli, $out);
|
||||||
return $ret;
|
return $ret;
|
||||||
@ -495,7 +503,8 @@ class EncryptTask extends AbstractTask
|
|||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
private function writeProjectFile() {
|
private function writeProjectFile()
|
||||||
|
{
|
||||||
// array used to build config file into
|
// array used to build config file into
|
||||||
$out = array();
|
$out = array();
|
||||||
// set the project destination
|
// set the project destination
|
||||||
@ -535,7 +544,8 @@ class EncryptTask extends AbstractTask
|
|||||||
*
|
*
|
||||||
* @return array Final config array
|
* @return array Final config array
|
||||||
*/
|
*/
|
||||||
private function mergeConfigFiles() {
|
private function mergeConfigFiles()
|
||||||
|
{
|
||||||
/*
|
/*
|
||||||
* Options are the order the arrays are in
|
* Options are the order the arrays are in
|
||||||
* F - Project File
|
* F - Project File
|
||||||
@ -591,7 +601,8 @@ class EncryptTask extends AbstractTask
|
|||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
private function switchSrcToTmp() {
|
private function switchSrcToTmp()
|
||||||
|
{
|
||||||
$ret = Console::executeCommand('mv ' . $this->source . ' ' . $this->ionSource, $out);
|
$ret = Console::executeCommand('mv ' . $this->source . ' ' . $this->ionSource, $out);
|
||||||
if (!$ret) {
|
if (!$ret) {
|
||||||
throw new ErrorWithMessageException ('Cant create tmp dir :' . $out, $ret);
|
throw new ErrorWithMessageException ('Cant create tmp dir :' . $out, $ret);
|
||||||
@ -611,7 +622,8 @@ class EncryptTask extends AbstractTask
|
|||||||
*
|
*
|
||||||
* return array
|
* return array
|
||||||
*/
|
*/
|
||||||
private function getOptionsFromYaml($options) {
|
private function getOptionsFromYaml($options)
|
||||||
|
{
|
||||||
$s = array();
|
$s = array();
|
||||||
$p = array();
|
$p = array();
|
||||||
foreach ($options as $key => $value) {
|
foreach ($options as $key => $value) {
|
||||||
@ -635,7 +647,8 @@ class EncryptTask extends AbstractTask
|
|||||||
* @param $fileName
|
* @param $fileName
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
private function getOptionsFromFile($fileName) {
|
private function getOptionsFromFile($fileName)
|
||||||
|
{
|
||||||
$s = array();
|
$s = array();
|
||||||
$p = array();
|
$p = array();
|
||||||
$fileContents = file_get_contents($fileName);
|
$fileContents = file_get_contents($fileName);
|
||||||
@ -693,7 +706,8 @@ class EncryptTask extends AbstractTask
|
|||||||
*
|
*
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
private function splitParam($string) {
|
private function splitParam($string)
|
||||||
|
{
|
||||||
$split = explode(PHP_EOL, $string);
|
$split = explode(PHP_EOL, $string);
|
||||||
if ($split === false) {
|
if ($split === false) {
|
||||||
// nothing found, so return a blank string
|
// nothing found, so return a blank string
|
||||||
@ -715,7 +729,8 @@ class EncryptTask extends AbstractTask
|
|||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
private function getOptionsDefault() {
|
private function getOptionsDefault()
|
||||||
|
{
|
||||||
$s = array();
|
$s = array();
|
||||||
$p = array();
|
$p = array();
|
||||||
// Set the switches
|
// Set the switches
|
||||||
|
@ -166,7 +166,9 @@ class Inline
|
|||||||
// array
|
// array
|
||||||
$keys = array_keys($value);
|
$keys = array_keys($value);
|
||||||
if ((1 == count($keys) && '0' == $keys[0])
|
if ((1 == count($keys) && '0' == $keys[0])
|
||||||
|| (count($keys) > 1 && array_reduce($keys, function ($v, $w) { return (int) $v + $w; }, 0) == count($keys) * (count($keys) - 1) / 2)
|
|| (count($keys) > 1 && array_reduce($keys, function ($v, $w) {
|
||||||
|
return (int)$v + $w;
|
||||||
|
}, 0) == count($keys) * (count($keys) - 1) / 2)
|
||||||
) {
|
) {
|
||||||
$output = array();
|
$output = array();
|
||||||
foreach ($value as $val) {
|
foreach ($value as $val) {
|
||||||
|
Loading…
Reference in New Issue
Block a user