1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
<?php
namespace Basho\Riak\Command\Builder;
use Basho\Riak\Bucket;
/**
* Allows easy code sharing for Bucket getters / setters within the Command Builders
*
* @author Christopher Mancini <cmancini at basho d0t com>
*/
trait BucketTrait
{
/**
* Stores the Bucket object
*
* @var Bucket|null
*/
protected $bucket = NULL;
/**
* Gets the Bucket object
*
* @return Bucket|null
*/
public function getBucket()
{
return $this->bucket;
}
/**
* Build a Bucket object to be added to the Command
*
* @param $name
* @param string $type
*
* @return $this
*/
public function buildBucket($name, $type = 'default')
{
$this->bucket = new Bucket($name, $type);
return $this;
}
/**
* Attach the provided Bucket to the Command
*
* @param Bucket $bucket
*
* @return $this
*/
public function inBucket(Bucket $bucket)
{
$this->bucket = $bucket;
return $this;
}
}