PluginProbe
Billingo Official for WooCommerce / 4.2.9
Billingo Official for WooCommerce v4.2.9
4.3.3 4.3.2 trunk 0.0.2 1.0.0 2.0 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 2.0.8 2.0.9 2.1.0 2.1.1 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.1.8 All 82 releases
billingo / src / Service / ApiContext.php

ApiContext.php in Billingo Official for WooCommerce 4.2.9, at src/Service/ApiContext.php

72 lines 1.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace App\Billingo\Service;
4
5 use App\Billingo\Enums\HttpMethodEnum;
6
7 class ApiContext
8 {
9 protected string $url;
10 protected array $content = [];
11 protected HttpMethodEnum $method;
12
13 public function getUrl(): string
14 {
15 return $this->url;
16 }
17
18 public function setUrl(string $url): self
19 {
20 $this->url = $url;
21
22 return $this;
23 }
24
25 public function getContent(): array
26 {
27 return $this->content;
28 }
29
30 public function setContent(array $content): self
31 {
32 $this->content = $content;
33
34 return $this;
35 }
36
37 public function getMethod(): HttpMethodEnum
38 {
39 return $this->method;
40 }
41
42 public function setMethod(HttpMethodEnum $method): self
43 {
44 $this->method = $method;
45
46 return $this;
47 }
48
49 public function fromArray(array $apiContext): self
50 {
51 $callableFunctions = [
52 'url' => 'setUrl',
53 'method' => 'setMethod',
54 'content' => 'setContent',
55 ];
56
57 array_walk($callableFunctions, function ($function, $name) use ($apiContext) {
58
59 if (isset($apiContext[$name])) {
60 $this->$function($apiContext[$name]);
61 }
62 });
63
64 return $this;
65 }
66
67 public function selfControl(): bool
68 {
69 return !empty($this->url) && !empty($this->method);
70 }
71 }
72