AppStoreInfo   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 1
lcom 1
cbo 3
dl 0
loc 24
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A lookup() 0 16 1
1
<?php
2
3
namespace SurajAdsul\AppMarket;
4
5
class AppStoreInfo extends AbstractStoreInfo
6
{
7
    private static $lookupUrl = 'https://itunes.apple.com/%s/lookup?id=%d';
8
9
    /**
10
     * @return array
11
     */
12
    protected function lookup()
13
    {
14
        $url = sprintf(self::$lookupUrl, $this->country, $this->storeId);
15
16
        $client = new HttpClient();
17
        $response = $client->get($url);
18
        $data = array_get(json_decode($response->getBody(), true), 'results.0');
19
        $this->name = array_get($data, 'trackCensoredName');
20
        $this->icon = array_get($data, 'artworkUrl512');
21
        $this->screenshots = array_merge(array_get($data, 'ipadScreenshotUrls', []), array_get($data, 'screenshotUrls', []));
22
        $this->ratingStars = round(array_get($data, 'averageUserRating', 0));
0 ignored issues
show
Documentation Bug introduced by
The property $ratingStars was declared of type integer, but round(array_get($data, 'averageUserRating', 0)) is of type double. Maybe add a type cast?

This check looks for assignments to scalar types that may be of the wrong type.

To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.

$answer = 42;

$correct = false;

$correct = (bool) $answer;
Loading history...
23
        $this->ratingCount = array_get($data, 'userRatingCount', 0);
24
        $this->contentRating = array_get($data, 'contentAdvisoryRating', '');
25
26
        return $data;
27
    }
28
}
29