/**
* Creates a new collection.
*
* @param string $title
* @param string $key
* @param string $locale
* @param int $userId
* @param int|null $parent id of parent collection or null for root
* @param int|null $id if not null a colleciton will be updated
*
* @return Collection
*/
private function createCollection($title, $key, $locale, $userId, $parent = null, $id = null)
{
$data = ['title' => $title, 'key' => $key, 'type' => ['id' => 2], 'locale' => $locale];
if ($parent !== null) {
$data['parent'] = $parent;
}
if ($id !== null) {
$data['id'] = $id;
}
return $this->collectionManager->save($data, $userId);
}