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 b09f55c commit c250915
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/Utils/ArrayWalker/ArrayWalkerTrait.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

namespace BiteIT\Utils;

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

public function getData($key, $defaultValue = null){
return $this->getWalker()->get($key, $defaultValue);
}

protected function getWalker(){
if(isset($this->walker))
return $this->walker;
return $this->walker = ArrayWalker::create($this->fetchData());
}

abstract protected function fetchData();
}

0 comments on commit c250915

Please sign in to comment.