NodesController::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 4
rs 10
c 1
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
namespace PHPHub\Http\ApiControllers;
4
5
use PHPHub\Repositories\NodeRepositoryInterface;
6
use PHPHub\Transformers\NodeTransformer;
7
8
class NodesController extends Controller
9
{
10
    /**
11
     * @var NodeRepositoryInterface
12
     */
13
    private $nodes;
14
15
    /**
16
     * TopicController constructor.
17
     *
18
     * @param NodeRepositoryInterface $repository
19
     */
20
    public function __construct(NodeRepositoryInterface $repository)
21
    {
22
        $this->nodes = $repository;
23
    }
24
25
    /**
26
     * 获取节点列表.
27
     *
28
     * @return \Illuminate\Http\Response
29
     */
30
    public function index()
31
    {
32
        $data = $this->nodes->all(['id', 'name', 'parent_node']);
33
34
        return $this->response()->collection($data, new NodeTransformer());
35
    }
36
}
37