Skip to content

Commit 0ead315

Browse files
committed
[EH] add getters
1 parent 1d45392 commit 0ead315

File tree

2 files changed

+59
-9
lines changed

2 files changed

+59
-9
lines changed

src/MigrationField.php

Lines changed: 46 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,17 @@
44

55
class MigrationField
66
{
7-
protected $name;
7+
private $name;
88

9-
protected $type;
9+
private $type;
1010

11-
protected $nullable = false;
11+
private $nullable = false;
1212

13-
protected $unique = false;
13+
private $unique = false;
1414

15-
protected $default = null;
15+
private $default = null;
1616

17-
protected $foreign = null;
17+
private $foreign = null;
1818

1919
public function __construct(string $field)
2020
{
@@ -53,4 +53,44 @@ private function fillObject(string $param)
5353
return $this->default = $match[1];
5454
}
5555
}
56+
57+
/**
58+
* @return string
59+
*/
60+
public function getName()
61+
{
62+
return $this->name;
63+
}
64+
65+
/**
66+
* @return string
67+
*/
68+
public function getType()
69+
{
70+
return $this->type;
71+
}
72+
73+
/**
74+
* @return mixed
75+
*/
76+
public function getDefault()
77+
{
78+
return $this->default;
79+
}
80+
81+
/**
82+
* @return bool
83+
*/
84+
public function isNullable()
85+
{
86+
return $this->nullable;
87+
}
88+
89+
/**
90+
* @return bool
91+
*/
92+
public function isUnique(): bool
93+
{
94+
return $this->unique;
95+
}
5696
}

src/MigrationSchema.php

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,26 @@
22

33
namespace Webfactor\Laravel\Generators;
44

5+
use Illuminate\Support\Collection;
6+
57
class MigrationSchema
68
{
7-
protected $schema;
9+
protected $structure;
810

911
public function __construct(string $schema)
1012
{
11-
$this->schema = collect();
13+
$this->structure = collect();
1214

1315
foreach (explode(',', $schema) as $field) {
14-
$this->schema->push(new MigrationField($field));
16+
$this->structure->push(new MigrationField($field));
1517
}
1618
}
19+
20+
/**
21+
* @return Collection
22+
*/
23+
public function getStructure(): Collection
24+
{
25+
return $this->structure;
26+
}
1727
}

0 commit comments

Comments
 (0)