Skip to content

Commit e1a5e4a

Browse files
committed
Create Stubs for PHP 7.4
1 parent 9361c34 commit e1a5e4a

7 files changed

+72
-0
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
2+
/**
3+
* @return {{ AttributeType }}
4+
*/
5+
public function get{{ GetterName }}(): {{ AttributeType }}
6+
{
7+
return $this->{{ AttributeName }};
8+
}
9+
10+
/**
11+
* @param {{ AttributeType }} ${{ AttributeName }}
12+
*/
13+
public function set{{ SetterName }}({{ AttributeType }} ${{ AttributeName }}): void
14+
{
15+
$this->{{ AttributeName }} = ${{ AttributeName }};
16+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
protected {{ AttributeType }} ${{ AttributeName }};
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?php
2+
3+
namespace {{ EntityNamespace }};
4+
5+
class {{ EntityName }} extends Entity
6+
{
7+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
3+
namespace {{ FactoryNamespace }};
4+
5+
use {{ EntityNamespace }}\{{ EntityName }};
6+
use stdClass;
7+
8+
class {{ FactoryName }} extends Factory
9+
{
10+
/**
11+
* @param stdClass $entity
12+
* @return {{ EntityName }}
13+
*/
14+
public function makeEntityFromStdClass(stdClass $entity): {{ EntityName }}
15+
{
16+
${{ EntityVariableName }} = new {{ EntityName }}();
17+
18+
19+
return ${{ EntityVariableName }};
20+
}
21+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
${{ EntityVariableName }}->set{{ SetterName }}($entity->{{ AttributeName }});
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
2+
/**
3+
* @param array ${{ AttributeNamePlural }}
4+
* @return Collection
5+
*/
6+
public function getAllBy{{ FunctionNamePlural }}(array ${{ AttributeNamePlural }}): Collection
7+
{
8+
${{ EntityVariableName }} = $this->newQuery()
9+
->whereIn('{{ AttributeName }}', ${{ AttributeNamePlural }})
10+
->get();
11+
12+
return $this->factory->makeCollectionOfEntities(${{ EntityVariableName }});
13+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
2+
/**
3+
* @param {{ AttributeType }} ${{ AttributeName }}
4+
* @return {{ EntityName }}|null
5+
*/
6+
public function getOneBy{{ FunctionName }}({{ AttributeType }} ${{ AttributeName }}): ?{{ EntityName }}
7+
{
8+
${{ EntityVariableName }} = $this->newQuery()
9+
->where('{{ AttributeName }}', ${{ AttributeName }})
10+
->first();
11+
12+
return ${{ EntityVariableName }} ? $this->factory->makeEntityFromStdClass(${{ EntityVariableName }}) : null;
13+
}

0 commit comments

Comments
 (0)