NodesController   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 29
rs 10
c 1
b 0
f 0
wmc 2
lcom 1
cbo 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A index() 0 6 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