Completed
Push — master ( 10fe91...543674 )
by Timur
02:34
created

ServiceCommand::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
namespace Laravel\Forge\Commands;
4
5
use Laravel\Forge\Contracts\ServiceContract;
6
use Laravel\Forge\Contracts\ResourceContract;
7
8
abstract class ServiceCommand extends ApiCommand
9
{
10
    /**
11
     * Associated service.
12
     *
13
     * @var \Laravel\Forge\Contracts\ServiceContract
14
     */
15
    protected $service;
16
17
    /**
18
     * Create new command instance.
19
     *
20
     * @param \Laravel\Forge\Contracts\ServiceContract $service
21
     */
22
    public function __construct(ServiceContract $service)
23
    {
24
        $this->service = $service;
25
    }
26
27
    /**
28
     * Associated service.
29
     *
30
     * @return \Laravel\Forge\Contracts\ServiceContract
31
     */
32
    public function getService(): ServiceContract
33
    {
34
        return $this->service;
35
    }
36
37
    /**
38
     * HTTP request URL.
39
     *
40
     * @param \Laravel\Forge\Contracts\ResourceContract $resource
41
     *
42
     * @return string
43
     */
44
    public function requestUrl(ResourceContract $resource)
45
    {
46
        return $resource->apiUrl('/'.$this->getService()->name().'/'.$this->command());
47
    }
48
}
49