forked from pavlokomarov/roach-php-core
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathShellCaster.php
More file actions
45 lines (38 loc) · 1.1 KB
/
ShellCaster.php
File metadata and controls
45 lines (38 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<?php
declare(strict_types=1);
/**
* Copyright (c) 2021 Kai Sassnowski
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*
* @see https://github.com/roach-php/roach
*/
namespace RoachPHP\Shell;
use RoachPHP\Http\Response;
use Symfony\Component\DomCrawler\Crawler;
use Symfony\Component\DomCrawler\Link;
use Symfony\Component\VarDumper\Caster\Caster;
final class ShellCaster
{
public static function castResponse(Response $response): array
{
return [
Caster::PREFIX_VIRTUAL . '.status' => $response->getStatus(),
Caster::PREFIX_VIRTUAL . '.uri' => $response->getUri(),
];
}
public static function castCrawler(Crawler $crawler): array
{
return [
Caster::PREFIX_VIRTUAL . '.count' => $crawler->count(),
Caster::PREFIX_VIRTUAL . '.html' => $crawler->outerHtml(),
];
}
public static function castLink(Link $link): array
{
return [
CASTER::PREFIX_PROTECTED . '.uri' => $link->getUri(),
];
}
}