update lock clucknut
All checks were successful
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 14s
Build, Push and Deploy / build-and-push (push) Successful in 3m14s
Build, Push and Deploy / deploy-staging (push) Successful in 25s
Build, Push and Deploy / deploy-production (push) Has been skipped

This commit is contained in:
2026-04-18 20:32:18 +07:00
parent 4554035227
commit dcaf267458
3359 changed files with 153185 additions and 205489 deletions

View File

@@ -0,0 +1,58 @@
<?php
namespace Twilio\Metadata;
use Iterator;
use ArrayIterator;
/**
* Wrapper containing an array along with HTTP response metadata (headers, status code).
* Allows access to response headers while maintaining backward compatibility.
*
* @template T of array
*/
class ArrayMetadata extends IteratorMetadata
{
/**
* @var array
*/
private $array;
/**
* Create array metadata wrapper.
*
* @param array $array the array returned by read()
* @param int $statusCode HTTP status code
* @param array<string, string> $headers HTTP response headers
*/
public function __construct(
array $array,
int $statusCode,
array $headers
) {
$this->array = $array;
// Convert array to ArrayIterator to satisfy parent constructor
$arrayIterator = new ArrayIterator($array);
parent::__construct($arrayIterator, $statusCode, $headers);
}
/**
* Get the original array.
*
* @return array
*/
public function getArray(): array
{
return $this->array;
}
/**
* String representation of the array metadata.
*
* @return string
*/
public function __toString(): string
{
return 'ArrayMetadata{' . parent::__toString();
}
}

View File

@@ -0,0 +1,141 @@
<?php
namespace Twilio\Metadata;
use Iterator;
/**
* Wrapper containing an iterator object along with HTTP response metadata (headers, status code).
* Allows access to response headers while maintaining backward compatibility.
*
* @template T of Iterator
*/
abstract class IteratorMetadata implements Iterator
{
/**
* @var T
*/
private $iterator;
/**
* @var array<string, string>
*/
private $headers;
/**
* @var int
*/
private $statusCode;
/**
* Create metadata wrapper.
*
* @param T $iterator the iterator object (Page, Stream etc.)
* @param int $statusCode HTTP status code
* @param array<string, string> $headers HTTP response headers
*/
public function __construct(
Iterator $iterator,
int $statusCode,
array $headers
) {
$this->iterator = $iterator;
$this->statusCode = $statusCode;
$this->headers = $headers;
}
/**
* Get the iterator.
*
* @return Iterator
*/
public function getIterator(): Iterator {
return $this->iterator;
}
/**
* Get HTTP response headers.
*
* @return array<string, string>
*/
public function getHeaders(): array
{
return $this->headers;
}
/**
* Get HTTP status code.
*
* @return int
*/
public function getStatusCode(): int
{
return $this->statusCode;
}
/**
* Get specific header value.
*
* @param string $headerName name of the header
* @return string|null header value or null if not present
*/
public function getHeader(string $headerName): ?string
{
return $this->headers[$headerName] ?? null;
}
/**
* String representation of the page metadata.
*
* @return string
*/
public function __toString(): string {
return 'statusCode=' . $this->getStatusCode() .
', headers=' . json_encode($this->getHeaders()) .
', array=' . json_encode($this->iterator) .
'}';
}
/**
* Implementation of Iterator interface
*/
/**
* (PHP 5 &gt;= 5.0.0)<br/>
* Return the current element
* @link http://php.net/manual/en/iterator.current.php
* @return mixed Can return any type.
*/
#[\ReturnTypeWillChange]
public function current()
{
return $this->iterator->current();
}
public function next(): void
{
$this->iterator->next();
}
/**
* (PHP 5 &gt;= 5.0.0)<br/>
* Return the key of the current element
* @link http://php.net/manual/en/iterator.key.php
* @return mixed scalar on success, or null on failure.
*/
#[\ReturnTypeWillChange]
public function key()
{
return $this->iterator->key();
}
public function valid(): bool
{
return $this->iterator->valid();
}
public function rewind(): void
{
$this->iterator->rewind();
}
}

View File

@@ -0,0 +1,75 @@
<?php
namespace Twilio\Metadata;
use Twilio\Page;
/**
* Wrapper containing a page along with HTTP response metadata (headers, status code).
* Allows access to response headers while maintaining backward compatibility.
*
* @template T of Page
*/
class PageMetadata extends IteratorMetadata
{
private $page;
/**
* @param Page $page
* @param int $statusCode
* @param array $headers
*/
public function __construct(
Page $page,
int $statusCode,
array $headers
) {
parent::__construct($page, $statusCode, $headers);
$this->page = $page;
}
/**
* Get the page.
*
* @return Page
*/
public function getPage(): Page
{
return $this->page;
}
public function nextPage(): ?PageMetadata
{
$nextPageUrl = $this->page->getNextPageUrl();
if (!$nextPageUrl) {
return null;
}
$response = $this->page->getResponse($nextPageUrl);
return new static(
$this->page->createPage($response),
$response->getStatusCode(),
$response->getHeaders()
);
}
public function previousPage(): ?PageMetadata
{
$previousPageUrl = $this->page->getPreviousPageUrl();
if (!$previousPageUrl) {
return null;
}
$response = $this->page->getResponse($previousPageUrl);
return new static(
$this->page->createPage($response),
$response->getStatusCode(),
$response->getHeaders()
);
}
public function __toString(): string
{
return 'ArrayMetadata{' . parent::__toString();
}
}

View File

@@ -0,0 +1,98 @@
<?php
namespace Twilio\Metadata;
use Twilio\InstanceResource;
/**
* Wrapper containing a resource along with HTTP response metadata (headers, status code).
* Allows access to response headers while maintaining backward compatibility.
*
* @template T of InstanceResource
*/
class ResourceMetadata
{
/**
* @var InstanceResource
*/
private $resource;
/**
* @var array<string, string>
*/
private $headers;
/**
* @var int
*/
private $statusCode;
/**
* Create response metadata wrapper.
*
* @param ?InstanceResource $resource the resource object (Message, Call, etc.)
* @param int $statusCode HTTP status code
* @param array<string, string> $headers HTTP response headers
*/
public function __construct(
?InstanceResource $resource,
int $statusCode,
array $headers
) {
$this->resource = $resource ?? true;
$this->statusCode = $statusCode;
$this->headers = $headers;
}
/**
* Get the resource.
*/
public function getResource() {
return $this->resource;
}
/**
* Get HTTP response headers.
*
* @return array<string, string>
*/
public function getHeaders(): array
{
return $this->headers;
}
/**
* Get HTTP status code.
*
* @return int
*/
public function getStatusCode(): int
{
return $this->statusCode;
}
/**
* Get specific header value.
*
* @param string $headerName name of the header
* @return string|null header value or null if not present
*/
public function getHeader(string $headerName): ?string
{
return $this->headers[$headerName] ?? null;
}
/**
* String representation of the response metadata.
*
* @return string
*/
public function __toString(): string
{
return 'ResourceMetadata{' .
'statusCode=' . $this->statusCode .
', headers=' . json_encode($this->headers) .
', resource=' . $this->resource .
'}';
}
}

View File

@@ -0,0 +1,47 @@
<?php
namespace Twilio\Metadata;
use Twilio\Page;
use Twilio\Stream;
use Iterator;
/**
* Wrapper containing a page along with HTTP response metadata (headers, status code).
* Allows access to response headers while maintaining backward compatibility.
*
* @template T of Stream
*/
class StreamMetadata extends IteratorMetadata
{
private $stream;
/**
* @param Stream $stream
* @param int $statusCode
* @param array $headers
*/
public function __construct(
Stream $stream,
int $statusCode,
array $headers
) {
parent::__construct($stream, $statusCode, $headers);
$this->stream = $stream;
}
/**
* Get the stream.
*
* @return Stream
*/
public function getStream(): Stream
{
return $this->stream;
}
public function __toString(): string
{
return 'StreamMetadata{' . parent::__toString();
}
}