Skip to content

Commit 359c15d

Browse files
authored
Merge pull request #15 from ProcessMaker/feature/FOUR-6588
Applying php-cs-fixer formatting
2 parents fa170f0 + d2856f1 commit 359c15d

7 files changed

Lines changed: 37 additions & 33 deletions

File tree

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
src/vendor
22
/sdk
3+
.php-cs-fixer.php
4+
.php-cs-fixer.cache

src/Api.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
<?php
2+
23
namespace Executor;
34

45
/**
56
* This helper allows you to use Api classes in the namespace
67
* ProcessMaker\Client\Api\ by calling its name as a function
78
* on an instance of this class. The class name is lowercase first.
8-
*
9+
*
910
* For example, to call \ProcessMaker\Client\Api\ProcessesApi
1011
* call $api->processes()
11-
*
1212
*/
13-
class Api {
14-
13+
class Api
14+
{
1515
/**
1616
* Reusable instances of api objects
1717
*
@@ -37,9 +37,10 @@ class Api {
3737
* Constructor
3838
*
3939
* @param \ProcessMaker\Client\Configuration $config
40-
* @param boolean $ssl_verify
40+
* @param bool $ssl_verify
4141
*/
42-
public function __construct($config, $ssl_verify) {
42+
public function __construct($config, $ssl_verify)
43+
{
4344
$this->client = new \GuzzleHttp\Client(['verify' => $ssl_verify]);
4445
$this->config = $config;
4546
}
@@ -54,18 +55,17 @@ public function __construct($config, $ssl_verify) {
5455
public function __call($name, $arguments)
5556
{
5657
if (count($arguments) > 0) {
57-
throw new \BadMethodCallException("Arguments should not be passed");
58+
throw new \BadMethodCallException('Arguments should not be passed');
5859
}
5960

6061
$class_name = $this->getClassName($name);
6162

6263
if (array_key_exists($class_name, $this->instances)) {
6364
return $this->instances[$class_name];
64-
6565
} elseif (class_exists($this->getClassName($name))) {
6666
$this->instances[$class_name] = new $class_name($this->client, $this->config);
67-
return $this->instances[$class_name];
6867

68+
return $this->instances[$class_name];
6969
} else {
7070
throw new \BadMethodCallException("class $class_name does not exist");
7171
}
@@ -79,6 +79,6 @@ public function __call($name, $arguments)
7979
*/
8080
private function getClassName($name)
8181
{
82-
return '\\ProcessMaker\\Client\Api\\' . ucfirst($name) . "Api";
82+
return '\\ProcessMaker\\Client\Api\\' . ucfirst($name) . 'Api';
8383
}
84-
}
84+
}

src/DockerExecutorPhpServiceProvider.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
<?php
2+
23
namespace ProcessMaker\Package\DockerExecutorPhp;
34

45
use Illuminate\Support\Facades\Route;
56
use Illuminate\Support\ServiceProvider;
6-
use ProcessMaker\Traits\PluginServiceProviderTrait;
77
use ProcessMaker\Models\ScriptExecutor;
8+
use ProcessMaker\Traits\PluginServiceProviderTrait;
89

910
class DockerExecutorPhpServiceProvider extends ServiceProvider
1011
{
@@ -23,12 +24,12 @@ public function boot()
2324
'language' => 'php',
2425
'title' => 'PHP Executor',
2526
'description' => 'Default PHP Executor',
26-
'config' => 'RUN composer require aws/aws-sdk-php:3.226.0'
27+
'config' => 'RUN composer require aws/aws-sdk-php:3.226.0',
2728
]);
28-
29+
2930
// Build the instance image. This is the same as if you were to build it from the admin UI
3031
\Artisan::call('processmaker:build-script-executor ' . $scriptExecutor->id);
31-
32+
3233
// Restart the workers so they know about the new supported language
3334
// \Artisan::call('horizon:terminate');
3435
});
@@ -39,7 +40,7 @@ public function boot()
3940
'name' => 'PHP',
4041
'runner' => 'PhpRunner',
4142
'mime_type' => 'application/x-php',
42-
'options' => ['invokerPackage' => "ProcessMaker\\Client"],
43+
'options' => ['invokerPackage' => 'ProcessMaker\\Client'],
4344
'init_dockerfile' => [
4445
'ARG SDK_DIR',
4546
'COPY $SDK_DIR /opt/sdk-php',

src/ScriptRunners/PhpRunner.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ public function config($code, array $dockerConfig)
1717
$dockerConfig['image'] = config('script-runners.php.image');
1818
$dockerConfig['command'] = 'php /opt/executor/bootstrap.php';
1919
$dockerConfig['inputs']['/opt/executor/script.php'] = $code;
20+
2021
return $dockerConfig;
2122
}
2223
}

src/TestDocs.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,14 @@ public function handle()
5252
}
5353

5454
try {
55-
foreach($codes as $code) {
55+
foreach ($codes as $code) {
5656
$this->runCode($code);
5757
}
58-
} catch(\ProcessMaker\Exception\ScriptException $e) {
58+
} catch (\ProcessMaker\Exception\ScriptException $e) {
5959
$stack = $e->getMessage();
6060
$stack = explode("\n", $stack);
6161
$stack = array_slice($stack, 0, 15);
62-
$stack = join("\n", $stack);
62+
$stack = implode("\n", $stack);
6363

6464
$this->info($stack);
6565
}
@@ -75,7 +75,7 @@ private function runCode($code)
7575
'timeout' => 60,
7676
]);
7777

78-
$result = $script->runScript([],[]);
78+
$result = $script->runScript([], []);
7979

8080
$script->delete();
8181

src/bootstrap.php

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
// Include our composer libraries
34
require __DIR__ . '/vendor/autoload.php';
45

@@ -13,25 +14,24 @@
1314
const CONFIG_JSON_INVALID = 101;
1415
const SCRIPT_PATH_INVALID = 102;
1516

16-
1717
$data = json_decode(@file_get_contents(DATA_JSON_PATH), true);
18-
if($data === null) {
18+
if ($data === null) {
1919
// Terminate script, the data is invalid json or cannot be ready
20-
fwrite(STDERR, "Data JSON file (" . DATA_JSON_PATH . ") does not exist or is invalid.");
20+
fwrite(STDERR, 'Data JSON file (' . DATA_JSON_PATH . ') does not exist or is invalid.');
2121
exit(DATA_JSON_INVALID);
2222
}
2323

2424
$config = json_decode(@file_get_contents(CONFIG_JSON_PATH), true);
25-
if($config === null) {
25+
if ($config === null) {
2626
// Terminate script, the config is invalid json or cannot be ready
27-
fwrite(STDERR, "Config JSON file (" . CONFIG_JSON_PATH . ") does not exist or is invalid.");
27+
fwrite(STDERR, 'Config JSON file (' . CONFIG_JSON_PATH . ') does not exist or is invalid.');
2828
exit(CONFIG_JSON_INVALID);
2929
}
3030

3131
// Check for existence of script
32-
if(!file_exists(SCRIPT_PATH)) {
32+
if (!file_exists(SCRIPT_PATH)) {
3333
// Terminate script, the config is invalid json or cannot be ready
34-
fwrite(STDERR, "Script file (" . SCRIPT_PATH . ") does not exist or is invalid.");
34+
fwrite(STDERR, 'Script file (' . SCRIPT_PATH . ') does not exist or is invalid.');
3535
exit(SCRIPT_PATH_INVALID);
3636
}
3737

@@ -42,9 +42,7 @@
4242
$api = new Executor\Api($api_config, isset($_ENV['API_SSL_VERIFY']) ? (bool) $_ENV['API_SSL_VERIFY'] : true);
4343
}
4444

45-
$response = require(SCRIPT_PATH);
45+
$response = require SCRIPT_PATH;
4646

4747
// Finally store the output of our script into our output JSON path
4848
file_put_contents(OUTPUT_JSON_PATH, json_encode($response));
49-
50-

src/tests/ApiTest.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
<?php
2+
23
use PHPUnit\Framework\TestCase;
34

45
class ApiTest extends TestCase
56
{
6-
const API_TOKEN = "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImp0aSI6IjQyN2RlODA3MzhiZWNmYzgyZGFiMDA4MTExYzQxYTFkZTM3NzYyYjg5MDYyYWQyZjcxZTAzYzAwNzk3YTc5NDBjY2U5MGFlM2IzZTE1MWE1In0.eyJhdWQiOiIxIiwianRpIjoiNDI3ZGU4MDczOGJlY2ZjODJkYWIwMDgxMTFjNDFhMWRlMzc3NjJiODkwNjJhZDJmNzFlMDNjMDA3OTdhNzk0MGNjZTkwYWUzYjNlMTUxYTUiLCJpYXQiOjE1NzkxMzY2NzQsIm5iZiI6MTU3OTEzNjY3NCwiZXhwIjoxNjEwNzU5MDc0LCJzdWIiOiIxIiwic2NvcGVzIjpbXX0.mQtWB8xclNpWMn6bpX6BnceJey8xu-IMicrzkLcbsTT9vXwvrn4e25Cbyzfahz7vwjqi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B8xclNpWMn6bpX6BnceJey8xu-IMicrzkLcbsTT9vXwvrn4e25Cbyzfahz7vwjqi10s2j7CeLJZwSkeF_k4f4uZsfJpDoTt08K1tYa_cRfpuoInP_2PhJnBIVZO2kdljJBwC3K_9gWgBzsGKS0I2fglSEycWaiIXWx5jAy8QS8hPYGPsrNG4YDTiNiUnYvbmY8c9JHbKS-yLtRZFEnkF7k-zUgSFKVz6WAwO2TcqCB_YX8RVKmnzG1KMgzXaGV-B4kCH5zdY74ZFLIwJalflTmA9jAgtaR3GsXeWqWXkxnPIIYHQdNlNONDqsJ1troo-3rH6hwZETRHKPVtrBAlR9q2k1SYRC9GUhC1otLJH0PXKiabUryIHPXC3cBavCYQ6MGEv2ou5ZfAuAAcKovWZd7-GDqwnDQxx-uMyIEiGrsZAt8EZiDFETHq1eBIGQLVezFbYhnOACYARWrMarZrQ6Q5yCKLrZ4KqIeaoJoPJOf8UJIQcpqhRAonfX_0RDLRWdbAW9ltfYkmfzWU2uJe15YqZu2wi9Bss0iGXWuRq2ASeNERgg_tkNe9ELQMxSKTx8D7tDe-g0Ja1QViLawmHK8XYDsmmKgOSMC9Xj-jd-Dg-ZjA3sMXWTEomudQyjQIBfdu68T4rGd_1lfneZAEEqtw9y2dKR7if13Fwar4';
8+
9+
const API_HOST = 'http://pm.local.processmaker.com/api/1.0';
810

911
public function testCallUserApi()
1012
{
@@ -23,4 +25,4 @@ public function testApiDoesNotExist()
2325
$this->expectException(BadMethodCallException::class);
2426
$this->assertEquals('ok', $api->foo()->getUsers());
2527
}
26-
}
28+
}

0 commit comments

Comments
 (0)