Completed
Pull Request — master (#52)
by John
03:28 queued 45s
created

SwaggerDocument::resolveSelfReferences()   B

Complexity

Conditions 5
Paths 5

Size

Total Lines 19
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 19
rs 8.8571
cc 5
eloc 11
nc 5
nop 2
1
<?php
2
/*
3
 * This file is part of the KleijnWeb\SwaggerBundle package.
4
 *
5
 * For the full copyright and license information, please view the LICENSE
6
 * file that was distributed with this source code.
7
 */
8
9
namespace KleijnWeb\SwaggerBundle\Document;
10
11
/**
12
 * @author John Kleijn <[email protected]>
13
 */
14
class SwaggerDocument
15
{
16
    /**
17
     * @var string
18
     */
19
    private $uri;
20
21
    /**
22
     * @var object
23
     */
24
    private $definition;
25
26
    /**
27
     * @var OperationObject[]
28
     */
29
    private $operations;
30
31
    /**
32
     * @param string $pathFileName
33
     * @param object $definition
34
     */
35
    public function __construct($pathFileName, $definition)
36
    {
37
        $this->uri = $pathFileName;
38
        $this->definition = $definition;
39
    }
40
41
    /**
42
     * @return object
43
     */
44
    public function getDefinition()
45
    {
46
        return $this->definition;
47
    }
48
49
    /**
50
     * @return object
51
     */
52
    public function getPathDefinitions()
53
    {
54
        return $this->definition->paths;
55
    }
56
57
    /**
58
     * @param string $path
59
     * @param string $method
60
     *
61
     * @return OperationObject
62
     */
63
    public function getOperationObject($path, $method)
64
    {
65
        $key = "$path::$method";
66
67
        if (isset($this->operations[$key])) {
68
            return $this->operations[$key];
69
        }
70
71
        return $this->operations[$key] = new OperationObject($this, $path, $method);
72
    }
73
74
    /**
75
     * @deprecated
76
     *
77
     * @param string $path
78
     * @param string $method
79
     *
80
     * @return object
81
     */
82
    public function getOperationDefinition($path, $method)
83
    {
84
        return $this->getOperationObject($path, $method)->getDefinition();
85
    }
86
}
87