Completed
Push — master ( a2e099...6941ff )
by Oscar
8s
created

Xing   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 48
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A shareUrl() 15 15 1
A shareCountRequest() 13 13 1
A shareCount() 6 6 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
namespace SocialLinks\Providers;
4
5 View Code Duplication
class Xing extends ProviderBase implements ProviderInterface
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
6
{
7
    /**
8
     * {@inheritdoc}
9
     */
10
    public function shareUrl()
11
    {
12
13
        /*
14
         * alternate request url:
15
         * https://www.xing-share.com/app/user?op=share;sc_p=xing-share;url=YOUR-URL
16
         */
17
18
        return $this->buildUrl(
19
            'https://www.xing.com/spi/shares/new',
20
            array(
21
                'url'
22
            )
23
        );
24
    }
25
26
    /**
27
     * {@inheritdoc}
28
     */
29
    public function shareCountRequest()
30
    {
31
        $url = $this->buildUrl(
32
            'https://www.xing-share.com/app/share',
33
            array('url'),
34
            array(
35
                "op" => "get_share_button",
36
                "counter" => 'top'
37
            )
38
        );
39
40
        return static::request($url);
41
    }
42
43
    /**
44
     * {@inheritdoc}
45
     */
46
    public function shareCount($response)
47
    {
48
        preg_match('/xing-count(.+?)(\d+)(.*?)<\/span>/i', $response, $matches);
49
50
        return (int)$matches[2];
51
    }
52
}
53