Skip to content

Commit

Permalink
Added Entity/File fo represent a file
Browse files Browse the repository at this point in the history
  • Loading branch information
Valentinas Bartusevičius committed Mar 8, 2021
1 parent 709e9a5 commit 70337bd
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 4 deletions.
5 changes: 1 addition & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,7 @@ dist: trusty
matrix:
include:
- php: 5.5
- php: 5.6
- php: 7.0
- php: 7.1
- php: 7.2
- php: 7.4
install:
- composer install

4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## 2.5.0
### Added
- Added `Entity/File` to represent a file.

## 2.4.2
### Fixed
- Throws `RuntimeException` when trying to create `RequestException` and response body is not seekable
Expand Down
81 changes: 81 additions & 0 deletions src/Entity/File.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
<?php

namespace Paysera\Component\RestClientCommon\Entity;

/**
* @api
*/
class File extends Entity
{
/**
* @return string|null
*/
public function getName()
{
return $this->get('name');
}

/**
* @return string
*/
public function getContent()
{
return $this->get('content');
}

/**
* @return string|null
*/
public function getMimeType()
{
return $this->get('mime_type');
}

/**
* @return int|null
*/
public function getSize()
{
return $this->get('size');
}

/**
* @param string|null $name
* @return $this
*/
public function setName($name)
{
$this->set('name', $name);
return $this;
}

/**
* @param string $content
* @return $this
*/
public function setContent($content)
{
$this->set('content', $content);
return $this;
}

/**
* @param string|null $mimeType
* @return $this
*/
public function setMimeType($mimeType)
{
$this->set('mime_type', $mimeType);
return $this;
}

/**
* @param int|null $size
* @return $this
*/
public function setSize($size)
{
$this->set('size', $size);
return $this;
}
}

1 comment on commit 70337bd

@zexa
Copy link

@zexa zexa commented on 70337bd Mar 8, 2021

Choose a reason for hiding this comment

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

Cute! I use a similar file representation.

Q: How do you ensure that the file content will not be distorted? Encode in base64? Raw bytes?

Please sign in to comment.