Skip to content

Commit d167f62

Browse files
committed
Even more codestyle
Signed-off-by: Roland Dalmulder <contact@rolandd.com>
1 parent aeb58be commit d167f62

File tree

1 file changed

+24
-46
lines changed

1 file changed

+24
-46
lines changed

administrator/components/com_patchtester/src/Model/PullModel.php

Lines changed: 24 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -525,7 +525,9 @@ private function applyWithGitHub(int $id): bool
525525
Text::sprintf(
526526
'COM_PATCHTESTER_COULD_NOT_CONNECT_TO_GITHUB',
527527
$exception->getMessage()
528-
), $exception->getCode(), $exception
528+
),
529+
$exception->getCode(),
530+
$exception
529531
);
530532
}
531533

@@ -556,11 +558,7 @@ private function applyWithGitHub(int $id): bool
556558
case 'modified':
557559
case 'renamed':
558560
// If the backup file already exists, we can't apply the patch
559-
if (file_exists(
560-
JPATH_COMPONENT . '/backups/' . md5($file->filename)
561-
. '.txt'
562-
)
563-
) {
561+
if (file_exists(JPATH_COMPONENT . '/backups/' . md5($file->filename) . '.txt')) {
564562
throw new RuntimeException(
565563
Text::sprintf(
566564
'COM_PATCHTESTER_CONFLICT_S',
@@ -569,11 +567,9 @@ private function applyWithGitHub(int $id): bool
569567
);
570568
}
571569

572-
if ($file->action === 'modified'
573-
&& !file_exists(
574-
JPATH_ROOT . '/' . $file->filename
575-
)
576-
) {
570+
if (
571+
$file->action === 'modified'
572+
&& !file_exists(JPATH_ROOT . '/' . $file->filename)) {
577573
throw new RuntimeException(
578574
Text::sprintf(
579575
'COM_PATCHTESTER_FILE_MODIFIED_DOES_NOT_EXIST_S',
@@ -611,7 +607,9 @@ private function applyWithGitHub(int $id): bool
611607
Text::sprintf(
612608
'COM_PATCHTESTER_COULD_NOT_CONNECT_TO_GITHUB',
613609
$exception->getMessage()
614-
), $exception->getCode(), $exception
610+
),
611+
$exception->getCode(),
612+
$exception
615613
);
616614
}
617615

@@ -624,16 +622,13 @@ private function applyWithGitHub(int $id): bool
624622
// We only create a backup if the file already exists
625623
if (
626624
$file->action === 'deleted'
627-
|| (file_exists(JPATH_ROOT . '/' . $file->filename)
628-
&& $file->action === 'modified')
629-
|| (file_exists(JPATH_ROOT . '/' . $file->originalFile)
630-
&& $file->action === 'renamed')
625+
|| (file_exists(JPATH_ROOT . '/' . $file->filename) && $file->action === 'modified')
626+
|| (file_exists(JPATH_ROOT . '/' . $file->originalFile) && $file->action === 'renamed')
631627
) {
632-
$filename = $file->action === 'renamed' ? $file->originalFile
633-
: $file->filename;
628+
$filename = $file->action === 'renamed' ? $file->originalFile : $file->filename;
634629
$src = JPATH_ROOT . '/' . $filename;
635-
$dest = JPATH_COMPONENT . '/backups/' . md5($filename)
636-
. '.txt';
630+
$dest = JPATH_COMPONENT . '/backups/' . md5($filename) . '.txt';
631+
637632
if (!File::copy(Path::clean($src), $dest)) {
638633
throw new RuntimeException(
639634
Text::sprintf(
@@ -648,11 +643,7 @@ private function applyWithGitHub(int $id): bool
648643
switch ($file->action) {
649644
case 'modified':
650645
case 'added':
651-
if (!File::write(
652-
Path::clean(JPATH_ROOT . '/' . $file->filename),
653-
$file->body
654-
)
655-
) {
646+
if (!File::write(Path::clean(JPATH_ROOT . '/' . $file->filename), $file->body)) {
656647
throw new RuntimeException(
657648
Text::sprintf(
658649
'COM_PATCHTESTER_ERROR_CANNOT_WRITE_FILE',
@@ -664,10 +655,7 @@ private function applyWithGitHub(int $id): bool
664655

665656
break;
666657
case 'deleted':
667-
if (!File::delete(
668-
Path::clean(JPATH_ROOT . '/' . $file->filename)
669-
)
670-
) {
658+
if (!File::delete(Path::clean(JPATH_ROOT . '/' . $file->filename))) {
671659
throw new RuntimeException(
672660
Text::sprintf(
673661
'COM_PATCHTESTER_ERROR_CANNOT_DELETE_FILE',
@@ -679,10 +667,7 @@ private function applyWithGitHub(int $id): bool
679667

680668
break;
681669
case 'renamed':
682-
if (!File::delete(
683-
Path::clean(JPATH_ROOT . '/' . $file->originalFile)
684-
)
685-
) {
670+
if (!File::delete(Path::clean(JPATH_ROOT . '/' . $file->originalFile))) {
686671
throw new RuntimeException(
687672
Text::sprintf(
688673
'COM_PATCHTESTER_ERROR_CANNOT_DELETE_FILE',
@@ -691,11 +676,7 @@ private function applyWithGitHub(int $id): bool
691676
);
692677
}
693678

694-
if (!File::write(
695-
Path::clean(JPATH_ROOT . '/' . $file->filename),
696-
$file->body
697-
)
698-
) {
679+
if (!File::write(Path::clean(JPATH_ROOT . '/' . $file->filename), $file->body)) {
699680
throw new RuntimeException(
700681
Text::sprintf(
701682
'COM_PATCHTESTER_ERROR_CANNOT_WRITE_FILE',
@@ -741,10 +722,7 @@ private function getFiles(int $id, int $page, array $files = []): array
741722
$id,
742723
$page
743724
);
744-
$files = array_merge(
745-
$files,
746-
json_decode($filesResponse->getBody(), false)
747-
);
725+
$files = array_merge($files, json_decode($filesResponse->getBody(), false));
748726
$lastPage = 1;
749727
$headers = $filesResponse->getHeaders();
750728

@@ -780,11 +758,11 @@ private function getFiles(int $id, int $page, array $files = []): array
780758
*/
781759
private function parseFileList(array $files): array
782760
{
783-
$parsedFiles = array();
761+
$parsedFiles = [];
784762
/*
785-
* Check if the patch tester is running in a development environment
786-
* If we are not in development, we'll need to check the exclusion lists
787-
*/
763+
* Check if the patch tester is running in a development environment
764+
* If we are not in development, we'll need to check the exclusion lists
765+
*/
788766
$isDev = file_exists(JPATH_INSTALLATION . '/index.php');
789767
foreach ($files as $file) {
790768
if (!$isDev) {

0 commit comments

Comments
 (0)