Subversion Repositories oidplus

Rev

Rev 1121 | Rev 1250 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1121 Rev 1130
Line 22... Line 22...
22
// phpcs:disable PSR1.Files.SideEffects
22
// phpcs:disable PSR1.Files.SideEffects
23
\defined('INSIDE_OIDPLUS') or die;
23
\defined('INSIDE_OIDPLUS') or die;
24
// phpcs:enable PSR1.Files.SideEffects
24
// phpcs:enable PSR1.Files.SideEffects
25
 
25
 
26
class OIDplusAid extends OIDplusObject {
26
class OIDplusAid extends OIDplusObject {
-
 
27
        /**
-
 
28
         * @var string
-
 
29
         */
27
        private $aid;
30
        private $aid;
28
 
31
 
29
        /**
32
        /**
30
         * @param $aid
33
         * @param string $aid
31
         */
34
         */
32
        public function __construct($aid) {
35
        public function __construct(string $aid) {
33
                // TODO: syntax checks
36
                // TODO: syntax checks
34
                $this->aid = $aid;
37
                $this->aid = $aid;
35
        }
38
        }
36
 
39
 
37
        /**
40
        /**
Line 126... Line 129...
126
        }
129
        }
127
 
130
 
128
        /**
131
        /**
129
         * @param OIDplusObject $parent
132
         * @param OIDplusObject $parent
130
         * @return string
133
         * @return string
-
 
134
         * @throws OIDplusException
131
         */
135
         */
132
        public function crudShowId(OIDplusObject $parent): string {
136
        public function crudShowId(OIDplusObject $parent): string {
133
                return $this->chunkedNotation(false);
137
                return $this->chunkedNotation(false);
134
        }
138
        }
135
 
139
 
136
        /**
140
        /**
137
         * @return string
141
         * @return string
-
 
142
         * @throws OIDplusException
138
         */
143
         */
139
        public function crudInsertPrefix(): string {
144
        public function crudInsertPrefix(): string {
140
                return $this->isRoot() ? '' : $this->chunkedNotation(false);
145
                return $this->isRoot() ? '' : $this->chunkedNotation(false);
141
        }
146
        }
142
 
147
 
Line 222... Line 227...
222
        }
227
        }
223
 
228
 
224
        # ---
229
        # ---
225
 
230
 
226
        /**
231
        /**
227
         * @param $withAbbr
232
         * @param bool $withAbbr
228
         * @return string
233
         * @return string
229
         * @throws OIDplusException
234
         * @throws OIDplusException
230
         */
235
         */
231
        public function chunkedNotation($withAbbr=true) {
236
        public function chunkedNotation(bool $withAbbr=true): string {
232
                $curid = self::root().$this->aid;
237
                $curid = self::root().$this->aid;
233
 
238
 
234
                $obj = OIDplusObject::findFitting($curid);
239
                $obj = OIDplusObject::findFitting($curid);
235
                if (!$obj) return $this->aid;
240
                if (!$obj) return $this->aid;
236
 
241
 
Line 270... Line 275...
270
        public function one_up()/*: ?OIDplusAid*/ {
275
        public function one_up()/*: ?OIDplusAid*/ {
271
                return self::parse($this->ns().':'.substr($this->aid,0,strlen($this->aid)-1));
276
                return self::parse($this->ns().':'.substr($this->aid,0,strlen($this->aid)-1));
272
        }
277
        }
273
 
278
 
274
        /**
279
        /**
275
         * @param $to
280
         * @param OIDplusObject|string $to
276
         * @return int|null
281
         * @return int|null
277
         */
282
         */
278
        public function distance($to) {
283
        public function distance($to) {
279
                if (!is_object($to)) $to = OIDplusObject::parse($to);
284
                if (!is_object($to)) $to = OIDplusObject::parse($to);
280
                if (!$to) return null;
285
                if (!$to) return null;