Skip to content

Commit 8802859

Browse files
committed
wip
1 parent 4e970f0 commit 8802859

File tree

3 files changed

+28
-2
lines changed

3 files changed

+28
-2
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ All notable changes to `dns` will be documented in this file
44

55
## 2.3.1 - 2021-11-02
66

7+
- fix macroable behaviour
8+
9+
## 2.3.1 - 2021-11-02
10+
711
- allow v1 of spatie/macroable
812

913
## 2.3.0 - 2021-11-02

src/Records/Record.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@
1717
*/
1818
abstract class Record implements Stringable
1919
{
20-
use Macroable;
20+
use Macroable {
21+
__call as protected macroCall;
22+
}
2123

2224
protected string $host;
2325
protected int $ttl;
@@ -72,7 +74,7 @@ public function __call(string $name, array $arguments)
7274
return $this->$name;
7375
}
7476

75-
throw new BadMethodCallException();
77+
return $this->macroCall($name, $arguments);
7678
}
7779

7880
protected static function lineToArray(string $line, ?int $limit = null): array

tests/Records/RecordTest.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?php
2+
3+
namespace Spatie\Dns\Test\Records;
4+
5+
use PHPUnit\Framework\TestCase;
6+
use Spatie\Dns\Records\A;
7+
use Spatie\Dns\Records\Record;
8+
9+
class RecordTest extends TestCase
10+
{
11+
/** @test */
12+
public function a_record_is_macroable()
13+
{
14+
Record::macro('ping', fn() => 'pong');
15+
16+
$record = A::parse('spatie.be. 900 IN A 138.197.187.74');
17+
18+
$this->assertEquals('pong', $record->ping());
19+
}
20+
}

0 commit comments

Comments
 (0)