Skip to content

Commit

Permalink
add FileManager::set()
Browse files Browse the repository at this point in the history
  • Loading branch information
Raphhh committed May 7, 2015
1 parent 546ada1 commit 7741e38
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/Manager/FileManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,15 @@ public function getAll()
return $result;
}

/**
* @param mixed $dataList
* @return int
*/
public function set($dataList)
{
return $this->fileReader->write($dataList);
}

/**
* @param mixed $data
* @return int
Expand All @@ -107,7 +116,7 @@ public function add($data)
}else{
$dataList[] = $data;
}
return $this->fileReader->write($dataList);
return $this->set($dataList);
}

/**
Expand Down Expand Up @@ -157,7 +166,7 @@ public function modify($id, $data)
$dataList = $this->getAll();
if(isset($dataList[$id])){
$dataList[$id] = $data;
return $this->fileReader->write($dataList);
return $this->set($dataList);
}
return 0;
}
Expand All @@ -183,7 +192,7 @@ public function remove($id)
{
$dataList = $this->getAll();
unset($dataList[$id]);
return $this->fileReader->write($dataList);
return $this->set($dataList);
}

/**
Expand All @@ -204,7 +213,7 @@ public function removeList(array $ids)
*/
public function removeAll()
{
return $this->fileReader->write(null);
return $this->set(null);
}

/**
Expand Down

0 comments on commit 7741e38

Please sign in to comment.