1: <?php
2: /**
3: * LICENSE (BSD)
4: *
5: * Copyright (c) 2013, Gerd Christian Kunze
6: * All rights reserved.
7: *
8: * Redistribution and use in source and binary forms, with or without
9: * modification, are permitted provided that the following conditions are
10: * met:
11: *
12: * * Redistributions of source code must retain the above copyright
13: * notice, this list of conditions and the following disclaimer.
14: *
15: * * Redistributions in binary form must reproduce the above copyright
16: * notice, this list of conditions and the following disclaimer in the
17: * documentation and/or other materials provided with the distribution.
18: *
19: * * Neither the name of Gerd Christian Kunze nor the names of the
20: * contributors may be used to endorse or promote products derived from
21: * this software without specific prior written permission.
22: *
23: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
24: * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
25: * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
26: * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
27: * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
28: * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
29: * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
30: * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
31: * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
32: * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33: * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34: *
35: * Package
36: * 03.06.2013 13:53
37: */
38: namespace MOC\Core\Depending;
39: use MOC\Api;
40: use MOC\Core\Version;
41: use MOC\Core\Changelog;
42: use MOC\Generic\Device\Core;
43:
44: /**
45: *
46: */
47: class Package implements Core {
48: /**
49: * Get Changelog
50: *
51: * @static
52: * @return \MOC\Core\Changelog
53: */
54: public static function InterfaceChangelog() {
55: return Api::Core()->Changelog();
56: }
57:
58: /**
59: * Get Dependencies
60: *
61: * @static
62: * @return \MOC\Core\Depending
63: */
64: public static function InterfaceDepending() {
65: return Api::Core()->Depending();
66: }
67:
68: /**
69: * Get Singleton/Instance
70: *
71: * @return Package
72: */
73: public static function InterfaceInstance() {
74: return new Package();
75: }
76:
77: /** @var string $Namespace */
78: private $Namespace = '';
79: /** @var string $Class */
80: private $Class = '';
81: /** @var Version $Version */
82: private $Version = null;
83: /** @var bool $Optional */
84: private $Optional = false;
85: /** @var Changelog $Changelog */
86: private $Changelog = false;
87:
88: /**
89: * @param string $Namespace
90: *
91: * @return Package
92: */
93: public function SetNamespace( $Namespace ) {
94: $this->Namespace = $Namespace;
95: return $this;
96: }
97:
98: /**
99: * @return string
100: */
101: public function GetNamespace() {
102: return $this->Namespace;
103: }
104:
105: /**
106: * @param string $Class
107: *
108: * @return Package
109: */
110: public function SetClass( $Class ) {
111: $this->Class = $Class;
112: return $this;
113: }
114:
115: /**
116: * @return string
117: */
118: public function GetClass() {
119: return $this->Class;
120: }
121:
122: /**
123: * @param Version $Version
124: *
125: * @return Package
126: */
127: public function SetVersion( Version $Version ) {
128: $this->Version = $Version;
129: return $this;
130: }
131:
132: /**
133: * @return Version
134: */
135: public function GetVersion() {
136: return $this->Version;
137: }
138:
139: /**
140: * @param Changelog $Changelog
141: *
142: * @return Package
143: */
144: public function SetChangelog( Changelog $Changelog ) {
145: $this->Changelog = $Changelog;
146: return $this;
147: }
148:
149: /**
150: * @return Changelog
151: */
152: public function GetChangelog() {
153: return $this->Changelog;
154: }
155:
156: /**
157: * @param bool $Optional
158: *
159: * @return Package
160: */
161: public function SetOptional( $Optional = false ) {
162: $this->Optional = $Optional;
163: return $this;
164: }
165:
166: /**
167: * @return bool
168: */
169: public function GetOptional() {
170: return $this->Optional;
171: }
172:
173: /**
174: * @return \MOC\Core\Drive\File
175: */
176: public function GetFile() {
177: $Directory = Api::Core()->Drive()->Directory()->Handle( __DIR__ . '/../../'.trim( preg_replace( '!MOC!', '', $this->Namespace, 1 ), '\\' ) );
178: return Api::Core()->Drive()->File()->Handle( $Directory->Location().DIRECTORY_SEPARATOR.$this->Class.'.php' );
179: }
180:
181: /**
182: * @return string
183: */
184: public function GetFQN() {
185: return trim( $this->Namespace.'\\'.$this->Class , '\\' );
186: }
187: }
188: