コード例 #1
0
ファイル: Interaction.php プロジェクト: Nycto/Round-Eights
 public function testConstruct()
 {
     $err = new \r8\Exception\Interaction('Variable was not set', 2020);
     $this->assertEquals("Variable was not set", $err->getMessage());
     $this->assertEquals(2020, $err->getCode());
     $this->assertEquals(array(), $err->getData());
 }
コード例 #2
0
ファイル: XMLBuilder.php プロジェクト: Nycto/Round-Eights
 /**
  * A helper function for building a node, ensuring a proper value was returned,
  * and then importing it into the document
  *
  * @param \r8\iface\XMLBuilder $builder
  * @param \DOMDocument $doc The document being built
  * @return DOMNode
  */
 public static function buildNode(\r8\iface\XMLBuilder $builder, \DOMDocument $doc)
 {
     $built = $builder->buildNode($doc);
     if (!$built instanceof \DOMNode) {
         $err = new \r8\Exception\Interaction("XMLBuilder did not return a DOMNode object");
         $err->addData("Document", \r8\getDump($doc));
         $err->addData("Built Node", \r8\getDump($built));
         throw $err;
     }
     // Ensure the built node is a member of the document
     return \r8\XMLBuilder::importNode($doc, $built);
 }
コード例 #3
0
ファイル: QueryParser.php プロジェクト: Nycto/Round-Eights
 /**
  * Takes a key string and parses it into any multi-dimensional parts it has
  *
  * @param String $key The key being parsed
  * @return Array Returns a list of the sub-keys
  */
 private function parseKey($key)
 {
     $found = preg_match_all($this->subRegEx, $key, $matches, PREG_OFFSET_CAPTURE);
     // If no sub-keys were found, just return the original key
     if (!$found) {
         return array($key);
     }
     // Grab the value of the key up to the position of the first match
     if ($matches[0][0][1] > 0) {
         $result = array(substr($key, 0, $matches[0][0][1]));
     } else {
         $result = array();
     }
     if (!isset($matches[1])) {
         $err = new \r8\Exception\Interaction("Sub-Key RegEx did not return a sub-pattern");
         $err->addData("Sub-Key RegEx", $this->subRegEx);
         throw $err;
     }
     // Loop through the matched sub-patterns
     foreach ($matches[1] as $subKey) {
         if (\r8\isEmpty($subKey[0], \r8\ALLOW_SPACES)) {
             $result[] = null;
         } else {
             $result[] = $subKey[0];
         }
     }
     return $result;
 }
コード例 #4
0
ファイル: Querier.php プロジェクト: Nycto/Round-Eights
 /**
  * Runs a query and returns a specific field from a row
  *
  * If no row is specified, the first row will be used
  *
  * @param String $field The field to return
  * @param String $query The query to execute
  * @param Integer $row The row of a multi-result set to pull the field from
  * @return Mixed Returns the value of the field, or NULL if no results
  *      were returned
  */
 public function getField($field, $query, $row = 0)
 {
     $field = (string) $field;
     if (\r8\isEmpty($field)) {
         throw new \r8\Exception\Argument(0, "Field", "Must not be empty");
     }
     $result = $this->getRow($query, $row);
     if (!is_array($result) && !$result instanceof \ArrayAccess) {
         $err = new \r8\Exception\Interaction("Row was not an array or accessable as an array");
         $err->addData("Query", $query);
         $err->addData("Returned Row", \r8\getDump($result));
         throw $err;
     }
     if (!isset($result[$field])) {
         $err = new \r8\Exception\Argument(0, "Field", "Field does not exist in row");
         $err->addData("Query", $query);
         $err->addData("Returned Row", \r8\getDump($result));
         throw $err;
     }
     return $result[$field];
 }
コード例 #5
0
ファイル: Mail.php プロジェクト: Nycto/Round-Eights
 /**
  * Internal function that actually sends a piece of mail using this transport.
  *
  * This method is called indirectly via the send method. Use that method
  * if you want to send a piece of mail
  *
  * @param \r8\Mail $mail The mail to send
  * @return Null
  */
 protected function internalSend(\r8\Mail $mail)
 {
     $result = $this->rawMail($this->formatter->getToString($mail), $mail->getSubject(), $this->formatter->getBody($mail), $this->formatter->getHeaderString($mail));
     if (!$result) {
         $err = new \r8\Exception\Interaction("An error occured while sending mail");
         $phpError = error_get_last();
         if (is_array($phpError)) {
             $err->addData('Error', $phpError['message']);
         }
         $err->addData('To', $this->formatter->getToString($mail));
         $err->addData('Subject', $mail->getSubject());
         if ($mail->messageIDExists()) {
             $err->addData('MessageID', $mail->getMessageID());
         }
         throw $err;
     }
 }