Passed
Push — feature/initial-implementation ( f3915b...fbd338 )
by Fike
02:22
created

AttachmentAware   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 11
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 11
rs 10
c 0
b 0
f 0
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A addDataAttachment() 0 7 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace AmaTeam\ElasticSearch\Test\Support\Allure;
6
7
use JMS\Serializer\SerializerBuilder;
8
use Yandex\Allure\Adapter\Support\AttachmentSupport;
9
10
trait AttachmentAware
11
{
12
    use AttachmentSupport;
13
14
    public function addDataAttachment($value, $title = 'data')
15
    {
16
        $tempFile = tempnam(sys_get_temp_dir(), 'ama-team-elasticsearch-');
17
        $serializer = (new SerializerBuilder())->build();
18
        $normalized = $serializer->serialize($value, 'yml');
19
        file_put_contents($tempFile, $normalized);
20
        $this->addAttachment($tempFile, "$title.yml");
21
    }
22
}
23