-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
69 changed files
with
1,506 additions
and
920 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?php declare(strict_types = 1); | ||
|
||
namespace Orisai\ObjectMapper\Context; | ||
|
||
use Orisai\ObjectMapper\Processing\Options; | ||
use Orisai\ObjectMapper\Processing\Processor; | ||
use Orisai\ObjectMapper\Types\Type; | ||
|
||
abstract class CallbackBaseContext | ||
{ | ||
|
||
private ServicesContext $services; | ||
|
||
private DynamicContext $dynamic; | ||
|
||
public function __construct( | ||
ServicesContext $services, | ||
DynamicContext $dynamic | ||
) | ||
{ | ||
$this->services = $services; | ||
$this->dynamic = $dynamic; | ||
} | ||
|
||
abstract public function getType(): Type; | ||
|
||
public function getProcessor(): Processor | ||
{ | ||
return $this->services->getProcessor(); | ||
} | ||
|
||
public function getOptions(): Options | ||
{ | ||
return $this->dynamic->getOptions(); | ||
} | ||
|
||
public function shouldInitializeObjects(): bool | ||
{ | ||
return $this->dynamic->shouldInitializeObjects(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php declare(strict_types = 1); | ||
|
||
namespace Orisai\ObjectMapper\Context; | ||
|
||
use Orisai\ObjectMapper\MappedObject; | ||
use Orisai\ObjectMapper\Types\MappedObjectType; | ||
|
||
final class CallbackObjectContext extends CallbackBaseContext | ||
{ | ||
|
||
/** @var ProcessorCallContext<MappedObject> */ | ||
private ProcessorCallContext $call; | ||
|
||
/** | ||
* @param ProcessorCallContext<MappedObject> $call | ||
*/ | ||
public function __construct( | ||
ServicesContext $services, | ||
DynamicContext $dynamic, | ||
ProcessorCallContext $call | ||
) | ||
{ | ||
parent::__construct($services, $dynamic); | ||
$this->call = $call; | ||
} | ||
|
||
public function getType(): MappedObjectType | ||
{ | ||
return $this->call->getType(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
<?php declare(strict_types = 1); | ||
|
||
namespace Orisai\ObjectMapper\Context; | ||
|
||
use Closure; | ||
use Orisai\ObjectMapper\Types\Type; | ||
|
||
final class CallbackPropertyContext extends CallbackBaseContext | ||
{ | ||
|
||
private PropertyContext $property; | ||
|
||
/** @var Closure(): Type */ | ||
private Closure $typeCreator; | ||
|
||
private ?Type $type = null; | ||
|
||
/** | ||
* @param Closure(): Type $typeCreator | ||
*/ | ||
public function __construct( | ||
ServicesContext $services, | ||
DynamicContext $dynamic, | ||
PropertyContext $property, | ||
Closure $typeCreator | ||
) | ||
{ | ||
parent::__construct($services, $dynamic); | ||
$this->property = $property; | ||
$this->typeCreator = $typeCreator; | ||
} | ||
|
||
public function getType(): Type | ||
{ | ||
if ($this->type !== null) { | ||
return $this->type; | ||
} | ||
|
||
$type = ($this->typeCreator)(); | ||
unset($this->typeCreator); | ||
|
||
return $this->type = $type; | ||
} | ||
|
||
public function getPropertyName(): string | ||
{ | ||
return $this->property->getPropertyName(); | ||
} | ||
|
||
/** | ||
* @return int|string | ||
*/ | ||
public function getFieldName() | ||
{ | ||
return $this->property->getFieldName(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.