Skip to content

Commit

Permalink
Remove crappy code...
Browse files Browse the repository at this point in the history
  • Loading branch information
Christopher Mancini committed May 27, 2015
1 parent aad6637 commit a3bc506
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 35 deletions.
45 changes: 16 additions & 29 deletions src/Basho/Riak/Bucket.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,19 +64,12 @@ public function getName()
/**
* Get the R-value for this bucket
*
* Returns the buckets R-value If it is set,
* otherwise return the R-value for the client.
*
* @param null $r
* Returns the buckets R-value If it is set, otherwise return the R-value for the client.
*
* @return int
*/
public function getR($r = null)
public function getR()
{
if ($r != null) {
return $r;
}

if ($this->r != null) {
return $this->r;
}
Expand Down Expand Up @@ -106,19 +99,12 @@ public function setR($r)
/**
* Get the W-value for this bucket
*
* If it is set for this bucket, otherwise return
* the W-value for the client.
*
* @param $w
* If it is set for this bucket, otherwise return the W-value for the client.
*
* @return int
*/
public function getW($w)
public function getW()
{
if ($w != null) {
return $w;
}

if ($this->w != null) {
return $this->w;
}
Expand All @@ -145,19 +131,12 @@ public function setW($w)
/**
* Get the DW-value for this bucket
*
* If it is set for this bucket, otherwise return
* the DW-value for the client.
*
* @param $dw
* If it is set for this bucket, otherwise return the DW-value for the client.
*
* @return int
*/
public function getDW($dw)
public function getDW()
{
if ($dw != null) {
return $dw;
}

if ($this->dw != null) {
return $this->dw;
}
Expand Down Expand Up @@ -223,13 +202,13 @@ public function newBinary($key = null, $data, $content_type = 'application/json'
*
* @param string $key - Name of the key.
* @param int $r - R-Value of the request (defaults to bucket's R)
*
* @return Object
*/
public function get($key, $r = null)
{
$obj = new Object($this->client, $this, $key);
$obj->jsonize = true;
$r = $this->getR($r);

return $obj->reload($r);
}
Expand All @@ -246,7 +225,6 @@ public function getBinary($key, $r = null)
{
$obj = new Object($this->client, $this, $key);
$obj->jsonize = false;
$r = $this->getR($r);

return $obj->reload($r);
}
Expand All @@ -261,6 +239,8 @@ public function getBinary($key, $r = null)
* only be used if you know what you are doing.
*
* @param integer $nval - The new N-Val.
*
* @return bool
*/
public function setNVal($nval)
{
Expand All @@ -286,6 +266,8 @@ public function getNVal()
* if you know what you are doing.
*
* @param boolean $bool - True to store and return conflicting writes.
*
* @return bool
*/
public function setAllowMultiples($bool)
{
Expand All @@ -309,6 +291,8 @@ public function getAllowMultiples()
*
* @param string $key - Property to set.
* @param mixed $value - Property value.
*
* @return bool
*/
public function setProperty($key, $value)
{
Expand Down Expand Up @@ -338,6 +322,7 @@ public function getProperty($key)
*
* @param array $props - An associative array of $key=>$value.
*
* @return bool
* @throws Exception
*/
public function setProperties($props)
Expand All @@ -360,6 +345,8 @@ public function setProperties($props)
if ($status != 204) {
throw new Exception("Error setting bucket properties.");
}

return true;
}

/**
Expand Down
14 changes: 8 additions & 6 deletions src/Basho/Riak/Object.php
Original file line number Diff line number Diff line change
Expand Up @@ -621,8 +621,8 @@ public function removeAllMeta()
public function store($w = null, $dw = null, $returnbody = 'true')
{
# Use defaults if not specified...
$w = $this->bucket->getW($w);
$dw = $this->bucket->getDW($dw);
$w = $w ? $w : $this->bucket->getW();
$dw = $dw ? $dw : $this->bucket->getDW();

$status_codes = array(200, 201, 300);
$method = 'POST';
Expand Down Expand Up @@ -716,15 +716,17 @@ public function store($w = null, $dw = null, $returnbody = 'true')
*
* @param integer $r - R-Value, wait for this many partitions to respond
* before returning to client.
*
* @return $this
*/
public function reload($r = null)
{
# Do the request...
$r = $this->bucket->getR($r);
$r = $r ? $r : $this->bucket->getR();
$params = array('r' => $r);
$url = Utils::buildRestPath($this->client, $this->bucket, $this->key, null, $params);

$response = Utils::httpRequest('GET', $url);

$this->populate($response, array(200, 300, 404));

# If there are siblings, load the data for the first one by default...
Expand All @@ -746,7 +748,7 @@ public function reload($r = null)
public function delete($dw = null)
{
# Use defaults if not specified...
$dw = $this->bucket->getDW($dw);
$dw = $dw ? $dw : $this->bucket->getDW();

# Construct the URL...
$params = array('dw' => $dw);
Expand Down Expand Up @@ -969,7 +971,7 @@ public function getSiblingCount()
public function getSibling($i, $r = null)
{
# Use defaults if not specified.
$r = $this->bucket->getR($r);
$r = $r ? $r : $this->bucket->getR();

# Run the request...
$vtag = $this->siblings[$i];
Expand Down

0 comments on commit a3bc506

Please sign in to comment.