Esempio n. 1
0
 public function testCloseClearProperties()
 {
     $handle = fopen('php://temp', 'r+');
     $stream = new Stream($handle);
     $stream->close();
     $this->assertFalse($stream->isSeekable());
     $this->assertFalse($stream->isReadable());
     $this->assertFalse($stream->isWritable());
     $this->assertNull($stream->getSize());
     $this->assertEmpty($stream->getMetadata());
 }
Esempio n. 2
0
 /**
  * Scopes: role_owner, role_admin
  *
  * @param string|resource $file
  * @return \Aikidesk\SDK\Instance\Contracts\ResponseInterface
  * @throws \Aikidesk\SDK\Instance\Exceptions\SDKValidationException
  */
 public function logo($file)
 {
     $input = [];
     if (is_string($file)) {
         $resource = fopen($file, 'r');
         $psr7Stream = new Stream($resource);
     } elseif (is_resource($file) and (get_resource_type($file) == 'file' or get_resource_type($file) == 'stream')) {
         $resource = $file;
         $psr7Stream = new Stream($resource);
     } else {
         throw new SDKValidationException('Logo is not file path nor file resource');
     }
     $fileContent = $psr7Stream->getContents();
     $fileType = pathinfo($psr7Stream->getMetadata('uri'), PATHINFO_EXTENSION);
     $fileName = pathinfo($psr7Stream->getMetadata('uri'), PATHINFO_FILENAME);
     $input['logo_img_s3key'] = 'data:image/' . $fileType . ';base64,' . base64_encode($fileContent) . ',' . $fileName;
     return $this->request->post('setting/theme', $input);
 }