Skip to content
This repository was archived by the owner on Jul 28, 2023. It is now read-only.

Commit 560eebe

Browse files
authored
Merge pull request #3 from spaceonfire/split-laminas-hydrator-bridge
Split laminas hydrator bridge
2 parents 6d42b57 + db2ee1c commit 560eebe

File tree

8 files changed

+20
-106
lines changed

8 files changed

+20
-106
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ on:
77
pull_request:
88
branches:
99
- master
10+
workflow_dispatch:
1011

1112
jobs:
1213
composer:

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@ Updates should follow the [Keep a CHANGELOG](http://keepachangelog.com/) princip
2222
- Nothing
2323
-->
2424

25+
## [1.2.0] - 2020-10-06
26+
### Deprecated
27+
- Class `spaceonfire\DataSource\Bridge\CycleOrm\Mapper\Hydrator\StdClassHydrator` moved to
28+
`spaceonfire/laminas-hydrator-bridge` library. Class alias provided for backwards compatibility,
29+
but will be removed in next major release.
30+
2531
## [1.1.0] - 2020-09-27
2632
### Deprecated
2733
- Namespace `spaceonfire\DataSource\Adapters` renamed to `spaceonfire\DataSource\Bridge`.

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
"jawira/case-converter": "^3.4",
2525
"spaceonfire/collection": "^2.0",
2626
"spaceonfire/criteria": "^1.1",
27+
"spaceonfire/laminas-hydrator-bridge": "^1.0",
2728
"webmozart/assert": "^1.6"
2829
},
2930
"require-dev": {
@@ -64,7 +65,7 @@
6465
},
6566
"extra": {
6667
"branch-alias": {
67-
"dev-master": "1.1-dev"
68+
"dev-master": "1.2-dev"
6869
}
6970
},
7071
"config": {

phpstan.neon.dist

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,6 @@ parameters:
1919
- '/^Unable to resolve the template type ExpectedType in call to method static method Webmozart\\Assert\\Assert::isInstanceOf\(\)$/'
2020
-
2121
message: '/^If condition is always false\.$/'
22-
path: src/Adapters/*
22+
paths:
23+
- src/Adapters/*
24+
- src/Bridge/CycleOrm/Mapper/Hydrator/StdClassHydrator.php

phpunit.xml.dist

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
<directory suffix=".php">src/</directory>
2020
<exclude>
2121
<directory>src/Adapters/</directory>
22+
<file>src/Bridge/CycleOrm/Mapper/Hydrator/StdClassHydrator.php</file>
2223
</exclude>
2324
</whitelist>
2425
</filter>

src/Bridge/CycleOrm/Mapper/Hydrator/StdClassHydrator.php

Lines changed: 6 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -4,53 +4,16 @@
44

55
namespace spaceonfire\DataSource\Bridge\CycleOrm\Mapper\Hydrator;
66

7-
use Laminas\Hydrator\AbstractHydrator;
7+
use function class_alias;
88

9-
class StdClassHydrator extends AbstractHydrator
10-
{
11-
/**
12-
* @inheritDoc
13-
*/
14-
public function extract(object $object): array
15-
{
16-
$data = get_object_vars($object);
17-
$filter = $this->getFilter();
18-
19-
/**
20-
* @var string $name
21-
* @var mixed $value
22-
*/
23-
foreach ($data as $name => $value) {
24-
// Filter keys, removing any we don't want
25-
if (!$filter->filter($name)) {
26-
unset($data[$name]);
27-
continue;
28-
}
29-
30-
// Replace name if extracted differ
31-
$extracted = $this->extractName($name, $object);
32-
33-
if ($extracted !== $name) {
34-
unset($data[$name]);
35-
$name = $extracted;
36-
}
37-
38-
$data[$name] = $this->extractValue($name, $value, $object);
39-
}
40-
41-
return $data;
42-
}
9+
class_alias(\spaceonfire\LaminasHydratorBridge\StdClassHydrator::class, __NAMESPACE__ . '\StdClassHydrator');
4310

11+
if (false) {
4412
/**
45-
* @inheritDoc
13+
* @deprecated Will be dropped in next major release.
14+
* Use \spaceonfire\LaminasHydratorBridge\StdClassHydrator instead.
4615
*/
47-
public function hydrate(array $data, object $object)
16+
class StdClassHydrator extends \spaceonfire\LaminasHydratorBridge\StdClassHydrator
4817
{
49-
foreach ($data as $name => $value) {
50-
$property = $this->hydrateName($name, $data);
51-
$object->$property = $this->hydrateValue($property, $value, $data);
52-
}
53-
54-
return $object;
5518
}
5619
}

src/Bridge/CycleOrm/Mapper/StdClassCycleMapper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
namespace spaceonfire\DataSource\Bridge\CycleOrm\Mapper;
66

77
use Cycle\ORM\ORMInterface;
8-
use spaceonfire\DataSource\Bridge\CycleOrm\Mapper\Hydrator\StdClassHydrator;
8+
use spaceonfire\LaminasHydratorBridge\StdClassHydrator;
99
use stdClass;
1010

1111
class StdClassCycleMapper extends BasicCycleMapper

tests/Bridge/CycleOrm/Mapper/Hydrator/StdClassHydratorTest.php

Lines changed: 0 additions & 60 deletions
This file was deleted.

0 commit comments

Comments
 (0)