Fixed setValue() being useless for CompoundTags and ListTags

This commit is contained in:
Dylan K. Taylor 2017-05-19 19:11:36 +01:00
parent f6c0ba9846
commit d4cc7d13cd
2 changed files with 20 additions and 0 deletions

View File

@ -49,6 +49,16 @@ class CompoundTag extends NamedTag implements \ArrayAccess{
return $count;
}
public function setValue($value){
if(is_array($value)){
foreach($value as $name => $tag){
if($tag instanceof NamedTag){
$this->{$name} = $tag;
}
}
}
}
public function offsetExists($offset){
return isset($this->{$offset}) and $this->{$offset} instanceof Tag;
}

View File

@ -48,6 +48,16 @@ class ListTag extends NamedTag implements \ArrayAccess, \Countable{
return $value;
}
public function setValue($value){
if(is_array($value)){
foreach($value as $name => $tag){
if($tag instanceof NamedTag){
$this->{$name} = $tag;
}
}
}
}
public function getCount(){
$count = 0;
foreach($this as $tag){