| 1 | package DBGp::Client::Response::Property; | ||
| 2 | |||
| 3 | use strict; | ||
| 4 | use warnings; | ||
| 5 | use parent qw(DBGp::Client::Response::Simple); | ||
| 6 | |||
| 7 | __PACKAGE__->make_attrib_accessors(qw( | ||
| 8 | name fullname constant type children address pagesize page classname key facet size | ||
| 9 | )); | ||
| 10 | |||
| 11 | sub numchildren { $_[0]->{attrib}{children} ? $_[0]->{attrib}{numchildren} : 0 } | ||
| 12 | |||
| 13 | sub value { | ||
| 14 | my $value = DBGp::Client::Parser::_node($_[0], 'value'); | ||
| 15 | |||
| 16 | if (!$value) { | ||
| 17 | # Xdebug compat | ||
| 18 | my $text = DBGp::Client::Parser::_text($_[0]); | ||
| 19 | |||
| 20 | return undef unless $text =~ /\S/; | ||
| 21 | |||
| 22 | my $encoding = $_[0]->{attrib}{encoding}; | ||
| 23 | return DBGp::Client::Parser::_decode($text, $encoding); | ||
| 24 | } | ||
| 25 | |||
| 26 | if (my $encoding = $value->{attrib}{encoding}) { | ||
| 27 | my $text = DBGp::Client::Parser::_text($value); | ||
| 28 | |||
| 29 | return length($text) ? DBGp::Client::Parser::_decode($text, $encoding) : undef; | ||
| 30 | } | ||
| 31 | } | ||
| 32 | |||
| 33 | sub childs { | ||
| 34 | return [] unless $_[0]->children; | ||
| 35 | |||
| 36 | return [ | ||
| 37 | map bless($_, 'DBGp::Client::Response::Property'), | ||
| 38 | DBGp::Client::Parser::_nodes($_[0], 'property'), | ||
| 39 | ]; | ||
| 40 | } | ||
| 41 | |||
| 42 | 1; |