Code Duplication    Length = 54-54 lines in 2 locations

src/PlaygroundCore/Controller/Plugin/Recaptcha.php 1 location

@@ 8-61 (lines=54) @@
5
use Zend\Mvc\Controller\Plugin\AbstractPlugin;
6
use Zend\ServiceManager\ServiceLocatorInterface;
7
8
class Recaptcha extends AbstractPlugin
9
{
10
    /**
11
     * @var ServiceLocator
12
     */
13
    protected $serviceLocator;
14
15
    /**
16
     * @var service
17
     */
18
    protected $service;
19
20
    public function __construct(ServiceLocatorInterface $locator)
21
    {
22
        $this->serviceLocator = $locator;
23
    }
24
25
    /**
26
     * Returns the Google ReCaptcha result
27
     *
28
     * @param string $response
29
     */
30
    public function recaptcha($response)
31
    {
32
        return $this->getService()->recaptcha($response);
33
    }
34
35
    /**
36
     * set service
37
     *
38
     * @param  $service
39
     * @return String
40
     */
41
    public function setService($service)
42
    {
43
        $this->service = $service;
44
45
        return $this;
46
    }
47
48
    /**
49
     * get mapper
50
     *
51
     * @return Service
52
     */
53
    public function getService()
54
    {
55
        if (!$this->service) {
56
            $this->setService($this->serviceLocator->get('playgroundcore_recaptcha_service'));
57
        }
58
59
        return $this->service;
60
    }
61
}
62

src/PlaygroundCore/Controller/Plugin/ShortenUrl.php 1 location

@@ 8-61 (lines=54) @@
5
use Zend\Mvc\Controller\Plugin\AbstractPlugin;
6
use Zend\ServiceManager\ServiceLocatorInterface;
7
8
class ShortenUrl extends AbstractPlugin
9
{
10
    /**
11
     * @var ServiceLocator
12
     */
13
    protected $serviceLocator;
14
15
    /**
16
     * @var service
17
     */
18
    protected $service;
19
20
    public function __construct(ServiceLocatorInterface $locator)
21
    {
22
        $this->serviceLocator = $locator;
23
    }
24
25
    /**
26
     * Returns a shortened Url via bit.ly
27
     *
28
     * @param string $longUrl
29
     */
30
    public function shortenUrl($longUrl)
31
    {
32
        return $this->getService()->shortenUrl($longUrl);
33
    }
34
35
    /**
36
     * set service
37
     *
38
     * @param  $service
39
     * @return String
40
     */
41
    public function setService($service)
42
    {
43
        $this->service = $service;
44
45
        return $this;
46
    }
47
48
    /**
49
     * get mapper
50
     *
51
     * @return Service
52
     */
53
    public function getService()
54
    {
55
        if (!$this->service) {
56
            $this->setService($this->serviceLocator->get('playgroundcore_shortenurl_service'));
57
        }
58
59
        return $this->service;
60
    }
61
}
62