for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/*
* This file is part of the xAPI package.
*
* (c) Christian Flothmann <[email protected]>
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Xabbuh\XApi\Client\Http;
use Xabbuh\XApi\Model\Attachment;
/**
* @author Christian Flothmann <[email protected]>
class AttachmentsBody
{
private $boundary;
private $json;
private $attachments;
* @param string $json
* @param Attachment[] $attachments
public function __construct($json, array $attachments)
$this->boundary = uniqid();
$this->json = $json;
$this->attachments = $attachments;
}
public function getBoundary()
return $this->boundary;
public function build()
$body = '--'.$this->boundary."\r\n";
$body .= "Content-Type: application/json\r\n";
$body .= 'Content-Length: '.strlen($this->json)."\r\n";
$body .= "\r\n";
$body .= $this->json."\r\n";
foreach ($this->attachments as $attachment) {
$body .= '--'.$this->boundary."\r\n";
$body .= 'Content-Type: '.$attachment->getContentType()."\r\n";
$body .= "Content-Transfer-Encoding: binary\r\n";
$body .= 'Content-Length: '.$attachment->getLength()."\r\n";
$body .= 'X-Experience-API-Hash: '.$attachment->getSha2()."\r\n";
$body .= $attachment->getContent()."\r\n";
getContent()
Xabbuh\XApi\Model\Attachment
getContentType()
This check marks calls to methods that do not seem to exist on an object.
This is most likely the result of a method being renamed without all references to it being renamed likewise.
$body .= '--'.$this->boundary.'--'."\r\n";
return $body;
This check marks calls to methods that do not seem to exist on an object.
This is most likely the result of a method being renamed without all references to it being renamed likewise.