Skip to content

Commit

Permalink
ArrayWalker trait
Browse files Browse the repository at this point in the history
  • Loading branch information
Sofiosko committed Sep 6, 2019
1 parent 737cfd2 commit cd3e99d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
5 changes: 2 additions & 3 deletions src/Utils/ArrayWalker/ArrayWalkerTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

trait ArrayWalkerTrait
{
protected $data = [];
protected $walker = null;

public function getData($key, $defaultValue = null){
Expand All @@ -14,8 +13,8 @@ public function getData($key, $defaultValue = null){
protected function getWalker(){
if(isset($this->walker))
return $this->walker;
return $this->walker = ArrayWalker::create($this->fetchData());
return $this->walker = ArrayWalker::create($this->getDataForWalker());
}

abstract protected function fetchData();
abstract protected function getDataForWalker();
}
4 changes: 2 additions & 2 deletions src/init.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ class ExampleDataStorage
]
];

public function getDataContainerName()
protected function getDataForWalker()
{
return 'data';
return $this->data;
}
}

0 comments on commit cd3e99d

Please sign in to comment.