Skip to content

Split API classes and interfaces #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jun 16, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 0 additions & 61 deletions docs/api/MongoDB/CRUD.php

This file was deleted.

19 changes: 19 additions & 0 deletions docs/api/MongoDB/Command/Command.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

namespace MongoDB\Command;

/**
* Value object for a database command document.
*/
final class Command
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This and Query do not have getter methods, since I assume their data will be accessed internally. Users shouldn't have any reason to read these objects after creating them.

{
private $document;

/**
* @param array|object $document Command document
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really want to have this as both array and object again?

*/
public function __construct($document)
{
$this->document = $document;
}
}
70 changes: 70 additions & 0 deletions docs/api/MongoDB/Command/CommandCursor.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<?php

namespace MongoDB\Command;

use MongoDB\Cursor;
use MongoDB\CursorId;

/**
* Cursor implementation that may be constructed from values found in a
* CommandResult's response document.
*
* The iteration and internal logic is very similar to QueryCursor, so both
* classes should likely share code. The first batch is comparable to the
* documents found in the OP_REPLY message returned by a QueryCursor's original
* OP_QUERY, in that both may be available at the time the cursor is
* constructed.
*/
final class CommandCursor implements Cursor
{
private $server;
private $batchSize;
private $cursorId;
private $firstBatch;

/**
* @param Server $server
* @param CursorId $cursorId
* @param array $firstBatch
*/
public function __construct(Server $server, CursorId $cursorId, array $firstBatch)
{
$this->server = $server;
$this->cursorId = $cursorId;
$this->firstBatch = $firstBatch;
}

// Iterator methods...

/**
* @return Cursor::getId()
*/
public function getId()
{
return $this->cursorId;
}

/**
* @see Cursor::getServer()
*/
public function getServer()
{
return $this->server;
}

/**
* @see Cursor::isDead()
*/
public function isDead()
{
// Return whether the cursor is exhausted and has no more results
}

/**
* @see \MongoDB\Cursor::setBatchSize()
*/
public function setBatchSize($batchSize)
{
$this->batchSize = (integer) $batchSize;
}
}
40 changes: 40 additions & 0 deletions docs/api/MongoDB/Command/CommandResult.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php

namespace MongoDB\Command;

use MongoDB\Server;

/**
* Result returned by Server and Manager executeCommand() methods.
*/
final class CommandResult
{
private $server;
private $responseDocument;

/**
* @param Server $server
* @param array|object $responseDocument
*/
public function __construct(Server $server, $responseDocument)
{
$this->server = $server;
$this->responseDocument = $responseDocument;
}

/**
* @return array Original response document from the server
*/
public function getResponseDocument()
{
return $this->responseDocument;
}

/**
* @return Server Server from which the result originated
*/
public function getServer()
{
return $this->server;
}
}
26 changes: 26 additions & 0 deletions docs/api/MongoDB/Cursor.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

namespace MongoDB;

interface Cursor extends \Iterator
{
/**
* @return CursorId
*/
function getId();

/**
* @return Server Server from which the cursor originated
*/
function getServer();

/**
* @return boolean Whether the cursor is exhausted and has no more results
*/
function isDead();

/**
* @param integer $batchSize
*/
function setBatchSize($batchSize);
}
35 changes: 35 additions & 0 deletions docs/api/MongoDB/CursorId.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

namespace MongoDB;

/**
* Value object for the 64-bit cursor identifier.
*
* This is useful for compatibility with 32-bit platforms, and also allows
* Cursor constructors to type-hint against a class.
*/
final class CursorId
{
// $id is an internal uint64_t value instead of a class property

/**
* @param integer|string $id
*/
public function __construct($id)
{
// Set internal uint64_t value
}

/**
* @return string
*/
public function __toString()
{
/* Return string representation of internal uint64_t value.
*
* This can be used to compare two CursorIds on a 32-bit platform. Is
* this functionality necessary, or should we do without any "getter"
* method?
*/
}
}
55 changes: 0 additions & 55 deletions docs/api/MongoDB/Management.php

This file was deleted.

Loading