作者 lackoxygen

feat:ann

... ... @@ -6,6 +6,12 @@ use Lackoxygen\TiktokShop\Util\Preg;
class Annotation
{
/**
* @param $class
* @param $method
* @return array
* @throws \ReflectionException
*/
public function method($class, $method): array
{
$ref = new \ReflectionClass($class);
... ...
... ... @@ -12,14 +12,29 @@ use Lackoxygen\TiktokShop\Util\Json;
class Mock
{
protected string $passage;
/**
* @var string
*/
protected string $request;
/**
* @var string
*/
protected string $method;
/**
* @var Annotation
*/
protected Annotation $annotation;
public function __construct(string $passage, string $method)
/**
* @param string $request
* @param string $method
*/
public function __construct(string $request, string $method)
{
$this->passage = $passage;
$this->request = $request;
$this->method = $method;
$this->annotation = new Annotation();
... ... @@ -75,10 +90,13 @@ class Mock
);
}
/**
* @return Response
*/
public function response(): Response
{
$methodAnnotation = $this->annotation->method(
$this->passage,
$this->request,
$this->method
);
... ... @@ -99,6 +117,10 @@ class Mock
return $response;
}
/**
* @param array $methodAnnotation
* @return false|mixed
*/
protected function extractUrlAnnotation(array $methodAnnotation)
{
$tag = '@link';
... ...
... ... @@ -6,8 +6,14 @@ use Lackoxygen\TiktokShop\Util\Json;
class Stream
{
protected string $content;
/**
* @var string|false|mixed
*/
protected string $content = '';
/**
* @param $content
*/
public function __construct($content)
{
if (is_array($content)) {
... ... @@ -16,6 +22,9 @@ class Stream
$this->content = $content;
}
/**
* @return string
*/
public function __toString(): string
{
return $this->content;
... ...