Passed
Push — main ( 7dc7cf...2fdc69 )
by Pranjal
02:49
created

Getter::getName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php
2
3
namespace Scrawler\Arca\Traits\Model;
4
use Scrawler\Arca\Collection;
5
trait Getter
6
{
7
8
    /**
9
     * Get current model Id or UUID
10
     * @return mixed
11
     */
12
    public function getId(): mixed
13
    {
14
        return $this->__meta['id'];
15
    }
16
17
    /**
18
     * Get current table name of model
19
     * @return string
20
     */
21
    public function getName(): string
22
    {
23
        return $this->table;
24
    }
25
26
    /**
27
     * Get all properties with relational models in array form
28
     * @return array<mixed>
29
     */
30
    public function getProperties(): array
31
    {
32
        return $this->__properties['all'];
33
    }
34
35
    /**
36
     * Get self properties without relations in array form
37
     * @return array<mixed>
38
     */
39
    public function getSelfProperties(): array
40
    {
41
        return $this->__properties['self'];
42
    }
43
44
    /**
45
     * Get all property types in array form
46
     * @return array<mixed>
47
     */
48
    public function getTypes(): array
49
    {
50
        return $this->__properties['type'];
51
    }
52
53
    /**
54
     * returns all relational models
55
     * @param string $type
56
     * @return Collection
57
     */
58
    public function getForeignModels(string $type): Collection
59
    {
60
        return is_null($this->__meta['foreign_models'][$type]) ? Collection::fromIterable([]) : $this->__meta['foreign_models'][$type];
61
    }
62
63
64
65
}