作者 lackoxygen

feat:ann

@@ -6,6 +6,12 @@ use Lackoxygen\TiktokShop\Util\Preg; @@ -6,6 +6,12 @@ use Lackoxygen\TiktokShop\Util\Preg;
6 6
7 class Annotation 7 class Annotation
8 { 8 {
  9 + /**
  10 + * @param $class
  11 + * @param $method
  12 + * @return array
  13 + * @throws \ReflectionException
  14 + */
9 public function method($class, $method): array 15 public function method($class, $method): array
10 { 16 {
11 $ref = new \ReflectionClass($class); 17 $ref = new \ReflectionClass($class);
@@ -12,14 +12,29 @@ use Lackoxygen\TiktokShop\Util\Json; @@ -12,14 +12,29 @@ use Lackoxygen\TiktokShop\Util\Json;
12 12
13 class Mock 13 class Mock
14 { 14 {
15 - protected string $passage; 15 + /**
  16 + * @var string
  17 + */
  18 + protected string $request;
  19 +
  20 + /**
  21 + * @var string
  22 + */
16 protected string $method; 23 protected string $method;
17 24
  25 + /**
  26 + * @var Annotation
  27 + */
18 protected Annotation $annotation; 28 protected Annotation $annotation;
19 29
20 - public function __construct(string $passage, string $method) 30 + /**
  31 + * @param string $request
  32 + * @param string $method
  33 + */
  34 + public function __construct(string $request, string $method)
21 { 35 {
22 - $this->passage = $passage; 36 + $this->request = $request;
  37 +
23 $this->method = $method; 38 $this->method = $method;
24 39
25 $this->annotation = new Annotation(); 40 $this->annotation = new Annotation();
@@ -75,10 +90,13 @@ class Mock @@ -75,10 +90,13 @@ class Mock
75 ); 90 );
76 } 91 }
77 92
  93 + /**
  94 + * @return Response
  95 + */
78 public function response(): Response 96 public function response(): Response
79 { 97 {
80 $methodAnnotation = $this->annotation->method( 98 $methodAnnotation = $this->annotation->method(
81 - $this->passage, 99 + $this->request,
82 $this->method 100 $this->method
83 ); 101 );
84 102
@@ -99,6 +117,10 @@ class Mock @@ -99,6 +117,10 @@ class Mock
99 return $response; 117 return $response;
100 } 118 }
101 119
  120 + /**
  121 + * @param array $methodAnnotation
  122 + * @return false|mixed
  123 + */
102 protected function extractUrlAnnotation(array $methodAnnotation) 124 protected function extractUrlAnnotation(array $methodAnnotation)
103 { 125 {
104 $tag = '@link'; 126 $tag = '@link';
@@ -6,8 +6,14 @@ use Lackoxygen\TiktokShop\Util\Json; @@ -6,8 +6,14 @@ use Lackoxygen\TiktokShop\Util\Json;
6 6
7 class Stream 7 class Stream
8 { 8 {
9 - protected string $content; 9 + /**
  10 + * @var string|false|mixed
  11 + */
  12 + protected string $content = '';
10 13
  14 + /**
  15 + * @param $content
  16 + */
11 public function __construct($content) 17 public function __construct($content)
12 { 18 {
13 if (is_array($content)) { 19 if (is_array($content)) {
@@ -16,6 +22,9 @@ class Stream @@ -16,6 +22,9 @@ class Stream
16 $this->content = $content; 22 $this->content = $content;
17 } 23 }
18 24
  25 + /**
  26 + * @return string
  27 + */
19 public function __toString(): string 28 public function __toString(): string
20 { 29 {
21 return $this->content; 30 return $this->content;