Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
15 / 15 |
|
100.00% |
5 / 5 |
CRAP | |
100.00% |
1 / 1 |
| AbstractHttp | |
100.00% |
15 / 15 |
|
100.00% |
5 / 5 |
11 | |
100.00% |
1 / 1 |
| __construct | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
2 | |||
| setClient | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
| getClient | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| hasClient | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| parseOptions | |
100.00% |
9 / 9 |
|
100.00% |
1 / 1 |
6 | |||
| createClient | n/a |
0 / 0 |
n/a |
0 / 0 |
0 | |||||
| 1 | <?php |
| 2 | /** |
| 3 | * Pop PHP Framework (https://www.popphp.org/) |
| 4 | * |
| 5 | * @link https://github.com/popphp/popphp-framework |
| 6 | * @author Nick Sagona, III <dev@noladev.com> |
| 7 | * @copyright Copyright (c) 2009-2026 NOLA Interactive, LLC. |
| 8 | * @license https://www.popphp.org/license New BSD License |
| 9 | */ |
| 10 | |
| 11 | /** |
| 12 | * @namespace |
| 13 | */ |
| 14 | namespace Pop\Mail\Api; |
| 15 | |
| 16 | use Pop\Http; |
| 17 | use Aws\Ses\SesClient; |
| 18 | |
| 19 | /** |
| 20 | * Abstract HTTP base class |
| 21 | * |
| 22 | * @category Pop |
| 23 | * @package Pop\Mail |
| 24 | * @author Nick Sagona, III <dev@noladev.com> |
| 25 | * @copyright Copyright (c) 2009-2026 NOLA Interactive, LLC. |
| 26 | * @license https://www.popphp.org/license New BSD License |
| 27 | * @version 4.0.7 |
| 28 | */ |
| 29 | abstract class AbstractHttp implements HttpInterface |
| 30 | { |
| 31 | |
| 32 | /** |
| 33 | * Client |
| 34 | * @var mixed |
| 35 | */ |
| 36 | protected mixed $client = null; |
| 37 | |
| 38 | /** |
| 39 | * Create Office 365 object |
| 40 | * |
| 41 | * @param array|string|null $options |
| 42 | */ |
| 43 | public function __construct(array|string|null $options = null) |
| 44 | { |
| 45 | if ($options !== null) { |
| 46 | $this->createClient($options); |
| 47 | } |
| 48 | } |
| 49 | |
| 50 | /** |
| 51 | * Set client |
| 52 | * |
| 53 | * @param mixed $client |
| 54 | * @return AbstractHttp |
| 55 | */ |
| 56 | public function setClient(mixed $client): AbstractHttp |
| 57 | { |
| 58 | $this->client = $client; |
| 59 | return $this; |
| 60 | } |
| 61 | |
| 62 | /** |
| 63 | * Get client |
| 64 | * |
| 65 | * @return mixed |
| 66 | */ |
| 67 | public function getClient(): mixed |
| 68 | { |
| 69 | return $this->client; |
| 70 | } |
| 71 | |
| 72 | /** |
| 73 | * Has client |
| 74 | * |
| 75 | * @return bool |
| 76 | */ |
| 77 | public function hasClient(): bool |
| 78 | { |
| 79 | return ($this->client !== null); |
| 80 | } |
| 81 | |
| 82 | /** |
| 83 | * Parse options |
| 84 | * |
| 85 | * @param array|string $options |
| 86 | * @throws Exception |
| 87 | * @return array |
| 88 | */ |
| 89 | public function parseOptions(array|string $options): array |
| 90 | { |
| 91 | if (is_string($options)) { |
| 92 | $jsonValue = @json_decode($options, true); |
| 93 | if ((json_last_error() === JSON_ERROR_NONE) && is_array($jsonValue)) { |
| 94 | $options = $jsonValue; |
| 95 | } else if (file_exists($options)) { |
| 96 | $options = @json_decode(file_get_contents($options), true); |
| 97 | } |
| 98 | |
| 99 | if (!is_array($options)) { |
| 100 | throw new Exception('Error: Unable to parse the options.'); |
| 101 | } |
| 102 | } |
| 103 | |
| 104 | return $options; |
| 105 | } |
| 106 | |
| 107 | /** |
| 108 | * Create client |
| 109 | * |
| 110 | * @param array|string $options |
| 111 | * @return AbstractHttp |
| 112 | */ |
| 113 | abstract public function createClient(array|string $options): AbstractHttp; |
| 114 | |
| 115 | } |