Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from laraXgram/0.1.x
Browse files Browse the repository at this point in the history
fix default mode type & change $datas to $data
AmirHkrg authored Jun 14, 2024
2 parents 9d089fd + 378d893 commit c19885f
Showing 2 changed files with 14 additions and 12 deletions.
14 changes: 8 additions & 6 deletions src/Methode.php
Original file line number Diff line number Diff line change
@@ -17,16 +17,18 @@ public function mode(Mode $mode): static

private function endpoint($method, $params): bool|array|string
{
if ($this->mode == 0){
$this->mode = $_ENV['DEFAULT_MODE'] ?? 32;
}
$this->mode = match ($_ENV['DEFAULT_MODE']) {
'curl' => 32,
'global' => 64,
default => 32
};

$params= array_filter($params, function($value) {
$params = array_filter($params, function ($value) {
return !is_null($value);
});

foreach ($params as $key => $value){
if (gettype($value) == 'object'){
foreach ($params as $key => $value) {
if (gettype($value) == 'object') {
$params[$key] = json_encode($value);
}
}
12 changes: 6 additions & 6 deletions src/Updates.php
Original file line number Diff line number Diff line change
@@ -49,20 +49,20 @@ trait Updates
public function __get($name)
{
if (isset($_ENV['UPDATE_TYPE']) && $_ENV['UPDATE_TYPE'] == 'global') {
global $datas;
$data = json_decode($datas['argv'][1]);
global $data;
$update = json_decode($data['argv'][1]);
} elseif ((isset($_ENV['UPDATE_TYPE']) && $_ENV['UPDATE_TYPE'] == 'sync') || !isset($_ENV['UPDATE_TYPE'])) {
$data = json_decode(file_get_contents('php://input'));
$update = json_decode(file_get_contents('php://input'));
}

return ($data->{$name}) ?? null;
return ($update->{$name}) ?? null;
}

public function getData()
{
if (isset($_ENV['UPDATE_TYPE']) && $_ENV['UPDATE_TYPE'] == 'global') {
global $datas;
return json_decode($datas['argv'][1]);
global $data;
return json_decode($data['argv'][1]);
} elseif ((isset($_ENV['UPDATE_TYPE']) && $_ENV['UPDATE_TYPE'] == 'sync') || !isset($_ENV['UPDATE_TYPE'])) {
return json_decode(file_get_contents('php://input'));
}

0 comments on commit c19885f

Please sign in to comment.