Ne-Lexa /
google-play-scraper
| 1 | <?php |
||
| 2 | |||
| 3 | declare(strict_types=1); |
||
| 4 | |||
| 5 | /* |
||
| 6 | * Copyright (c) Ne-Lexa |
||
| 7 | * |
||
| 8 | * For the full copyright and license information, please view |
||
| 9 | * the LICENSE file that was distributed with this source code. |
||
| 10 | * |
||
| 11 | * @see https://github.com/Ne-Lexa/google-play-scraper |
||
| 12 | */ |
||
| 13 | |||
| 14 | namespace Nelexa\GPlay\Model; |
||
| 15 | |||
| 16 | use Nelexa\GPlay\GPlayApps; |
||
| 17 | |||
| 18 | /** |
||
| 19 | * Contains review of application on Google Play store. |
||
| 20 | * |
||
| 21 | * @see GPlayApps::getReviews() Returns reviews of the Android app |
||
| 22 | * in the Google Play store. |
||
| 23 | * @see GPlayApps::getAppsInfo() Returns detailed information about many |
||
| 24 | * android packages. |
||
| 25 | */ |
||
| 26 | class Review implements \JsonSerializable |
||
| 27 | { |
||
| 28 | use JsonSerializableTrait; |
||
| 29 | |||
| 30 | /** @var string review id */ |
||
| 31 | private $id; |
||
| 32 | |||
| 33 | /** @var string review author */ |
||
| 34 | private $userName; |
||
| 35 | |||
| 36 | /** @var string review text */ |
||
| 37 | private $text; |
||
| 38 | |||
| 39 | /** @var GoogleImage author's avatar */ |
||
| 40 | private $avatar; |
||
| 41 | |||
| 42 | /** @var \DateTimeInterface|null review date */ |
||
| 43 | private $date; |
||
| 44 | |||
| 45 | /** @var int review score */ |
||
| 46 | private $score; |
||
| 47 | |||
| 48 | /** @var int the number of likes reviews */ |
||
| 49 | private $countLikes; |
||
| 50 | |||
| 51 | /** @var ReplyReview|null reply review */ |
||
| 52 | private $reply; |
||
| 53 | |||
| 54 | /** @var string|null */ |
||
| 55 | private $appVersion; |
||
| 56 | |||
| 57 | /** |
||
| 58 | * Creates an Android app review object in the Google Play store. |
||
| 59 | * |
||
| 60 | * @param string $id review id |
||
| 61 | * @param string $userName review author |
||
| 62 | * @param string $text review text |
||
| 63 | * @param GoogleImage $avatar author's avatar |
||
| 64 | * @param \DateTimeInterface|null $date review date |
||
| 65 | * @param int $score review score |
||
| 66 | * @param int $likeCount the number of likes reviews |
||
| 67 | * @param ReplyReview|null $reply reply review |
||
| 68 | * @param string|null $appVersion application version |
||
| 69 | */ |
||
| 70 | 11 | public function __construct( |
|
| 71 | string $id, |
||
| 72 | // string $url, |
||
| 73 | string $userName, |
||
| 74 | string $text, |
||
| 75 | GoogleImage $avatar, |
||
| 76 | ?\DateTimeInterface $date, |
||
| 77 | int $score, |
||
| 78 | int $likeCount = 0, |
||
| 79 | ?ReplyReview $reply = null, |
||
| 80 | ?string $appVersion = null |
||
| 81 | ) { |
||
| 82 | 11 | $this->id = $id; |
|
| 83 | 11 | $this->userName = $userName; |
|
| 84 | 11 | $this->text = $text; |
|
| 85 | 11 | $this->avatar = $avatar; |
|
| 86 | 11 | $this->date = $date; |
|
| 87 | 11 | $this->score = $score; |
|
| 88 | 11 | $this->countLikes = $likeCount; |
|
| 89 | 11 | $this->reply = $reply; |
|
| 90 | 11 | $this->appVersion = $appVersion; |
|
| 91 | } |
||
| 92 | |||
| 93 | /** |
||
| 94 | * Returns review id. |
||
| 95 | * |
||
| 96 | * @return string review id |
||
| 97 | */ |
||
| 98 | public function getId(): string |
||
| 99 | { |
||
| 100 | return $this->id; |
||
| 101 | } |
||
| 102 | |||
| 103 | /** |
||
| 104 | * @deprecated URL no longer available |
||
| 105 | */ |
||
| 106 | public function getUrl(): string |
||
| 107 | { |
||
| 108 | return ''; |
||
| 109 | } |
||
| 110 | |||
| 111 | /** |
||
| 112 | * Returns the username of the review author. |
||
| 113 | * |
||
| 114 | * @return string author's username |
||
| 115 | */ |
||
| 116 | public function getUserName(): string |
||
| 117 | { |
||
| 118 | return $this->userName; |
||
| 119 | } |
||
| 120 | |||
| 121 | /** |
||
| 122 | * Returns the text of the review. |
||
| 123 | * |
||
| 124 | * @return string review text |
||
| 125 | */ |
||
| 126 | public function getText(): string |
||
| 127 | { |
||
| 128 | return $this->text; |
||
| 129 | } |
||
| 130 | |||
| 131 | /** |
||
| 132 | * Returns the user's avatar. |
||
| 133 | * |
||
| 134 | * @return GoogleImage author's avatar |
||
| 135 | */ |
||
| 136 | public function getAvatar(): GoogleImage |
||
| 137 | { |
||
| 138 | return $this->avatar; |
||
| 139 | } |
||
| 140 | |||
| 141 | /** |
||
| 142 | * Returns the date of the review. |
||
| 143 | * |
||
| 144 | * @return \DateTimeInterface|null date of the review or null if not provided |
||
| 145 | */ |
||
| 146 | public function getDate(): ?\DateTimeInterface |
||
| 147 | { |
||
| 148 | return $this->date; |
||
| 149 | } |
||
| 150 | |||
| 151 | /** |
||
| 152 | * Returns a review rating. |
||
| 153 | * |
||
| 154 | * @return int review score |
||
| 155 | */ |
||
| 156 | public function getScore(): int |
||
| 157 | { |
||
| 158 | return $this->score; |
||
| 159 | } |
||
| 160 | |||
| 161 | /** |
||
| 162 | * Returns the count of likes of the review. |
||
| 163 | * |
||
| 164 | * @return int the number of likes reviews |
||
| 165 | */ |
||
| 166 | public function getCountLikes(): int |
||
| 167 | { |
||
| 168 | return $this->countLikes; |
||
| 169 | } |
||
| 170 | |||
| 171 | /** |
||
| 172 | * Returns a reply of the review. |
||
| 173 | * |
||
| 174 | * @return ReplyReview|null response to a review or null if not provided |
||
| 175 | */ |
||
| 176 | public function getReply(): ?ReplyReview |
||
| 177 | { |
||
| 178 | return $this->reply; |
||
| 179 | } |
||
| 180 | |||
| 181 | /** |
||
| 182 | * Returns the version of the application for which the comment was made. |
||
| 183 | * |
||
| 184 | * @return string|null application version |
||
| 185 | */ |
||
| 186 | public function getAppVersion(): ?string |
||
| 187 | { |
||
| 188 | return $this->appVersion; |
||
| 189 | } |
||
| 190 | |||
| 191 | /** |
||
| 192 | * Returns class properties as an array. |
||
| 193 | * |
||
| 194 | * @return array class properties as an array |
||
| 195 | */ |
||
| 196 | public function asArray(): array |
||
| 197 | { |
||
| 198 | return [ |
||
| 199 | 'id' => $this->id, |
||
| 200 | 'userName' => $this->userName, |
||
| 201 | 'text' => $this->text, |
||
| 202 | 'avatar' => $this->avatar->getUrl(), |
||
| 203 | 'appVersion' => $this->appVersion, |
||
| 204 | 'date' => $this->date->format(\DateTime::RFC3339), |
||
|
0 ignored issues
–
show
|
|||
| 205 | 'timestamp' => $this->date->getTimestamp(), |
||
| 206 | 'score' => $this->score, |
||
| 207 | 'countLikes' => $this->countLikes, |
||
| 208 | 'reply' => $this->reply ? $this->reply->asArray() : null, |
||
| 209 | ]; |
||
| 210 | } |
||
| 211 | } |
||
| 212 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.