PlayStoreInfo   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
B lookup() 0 27 3
1
<?php
2
3
namespace SurajAdsul\AppMarket;
4
5
class PlayStoreInfo extends AbstractStoreInfo
6
{
7
    private static $lookupUrl = 'https://play.google.com/store/apps/details?id=%s';
8
9
    /**
10
     * @return array
11
     */
12
    protected function lookup()
13
    {
14
        $url = sprintf(self::$lookupUrl, $this->storeId);
15
16
        $client = new CrawlerClient();
17
        $crawler = $client->request('GET', $url);
18
19
        $this->name = $crawler->filter('[itemprop="name"]')->text();
20
21
        $crawler->filter('div.score-container meta')->each(function ($node) {
22
            switch ($node->attr('itemprop')) {
23
                case 'ratingValue':
24
                    $this->ratingStars = round($node->attr('content'));
0 ignored issues
show
Documentation Bug introduced by
The property $ratingStars was declared of type integer, but round($node->attr('content')) 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...
25
                    break;
26
                case 'ratingCount':
27
                    $this->ratingCount = $node->attr('content');
28
            }
29
        });
30
31
//        $this->contentRating = $crawler->filter('[itemprop="contentRating"]')->text();
0 ignored issues
show
Unused Code Comprehensibility introduced by
62% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
32
        $iconUrl = $crawler->filter('[itemprop="image"]')->attr('src');
33
        $this->icon = $this->addScheme($iconUrl);
34
35
        $crawler->filter('[alt="Screenshot Image"]')->each(function ($node) {
36
            $this->screenshots[] = $this->addScheme($node->attr('src'));
37
        });
38
    }
39
}
40