aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private/legacy
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2017-02-22 12:17:55 +0100
committerJoas Schilling <coding@schilljs.com>2017-02-22 14:53:15 +0100
commit079888f918a915bdbdb6c0907a293cd495754317 (patch)
tree91edd22e85ad01f3bde66d392e750fe785b49a9e /lib/private/legacy
parent1e281bc616fc0034a4098999cf83d0d1115f5bb8 (diff)
downloadnextcloud-server-079888f918a915bdbdb6c0907a293cd495754317.tar.gz
nextcloud-server-079888f918a915bdbdb6c0907a293cd495754317.zip
Fix code quality a bit
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'lib/private/legacy')
-rw-r--r--lib/private/legacy/image.php30
1 files changed, 17 insertions, 13 deletions
diff --git a/lib/private/legacy/image.php b/lib/private/legacy/image.php
index 05367bbfde4..ed7dfce29a6 100644
--- a/lib/private/legacy/image.php
+++ b/lib/private/legacy/image.php
@@ -83,9 +83,9 @@ class OC_Image implements \OCP\IImage {
* @param \OCP\ILogger $logger
* @param \OCP\IConfig $config
*/
- public function __construct($imageRef = null, $logger = null, \OCP\IConfig $config = null) {
+ public function __construct($imageRef = null, \OCP\ILogger $logger = null, \OCP\IConfig $config = null) {
$this->logger = $logger;
- if (is_null($logger)) {
+ if ($logger === null) {
$this->logger = \OC::$server->getLogger();
}
$this->config = $config;
@@ -97,7 +97,7 @@ class OC_Image implements \OCP\IImage {
$this->fileInfo = new finfo(FILEINFO_MIME_TYPE);
}
- if (!is_null($imageRef)) {
+ if ($imageRef !== null) {
$this->load($imageRef);
}
}
@@ -212,11 +212,13 @@ class OC_Image implements \OCP\IImage {
if ($mimeType === null) {
$mimeType = $this->mimeType();
}
- if ($filePath === null && $this->filePath === null) {
- $this->logger->error(__METHOD__ . '(): called with no path.', array('app' => 'core'));
- return false;
- } elseif ($filePath === null && $this->filePath !== null) {
- $filePath = $this->filePath;
+ if ($filePath === null) {
+ if ($this->filePath === null) {
+ $this->logger->error(__METHOD__ . '(): called with no path.', array('app' => 'core'));
+ return false;
+ } else {
+ $filePath = $this->filePath;
+ }
}
return $this->_output($filePath, $mimeType);
}
@@ -231,12 +233,14 @@ class OC_Image implements \OCP\IImage {
*/
private function _output($filePath = null, $mimeType = null) {
if ($filePath) {
- if (!file_exists(dirname($filePath)))
+ if (!file_exists(dirname($filePath))) {
mkdir(dirname($filePath), 0777, true);
- if (!is_writable(dirname($filePath))) {
+ }
+ $isWritable = is_writable(dirname($filePath));
+ if (!$isWritable) {
$this->logger->error(__METHOD__ . '(): Directory \'' . dirname($filePath) . '\' is not writable.', array('app' => 'core'));
return false;
- } elseif (is_writable(dirname($filePath)) && file_exists($filePath) && !is_writable($filePath)) {
+ } elseif ($isWritable && file_exists($filePath) && !is_writable($filePath)) {
$this->logger->error(__METHOD__ . '(): File \'' . $filePath . '\' is not writable.', array('app' => 'core'));
return false;
}
@@ -350,7 +354,7 @@ class OC_Image implements \OCP\IImage {
/**
* @return string - base64 encoded, which is suitable for embedding in a VCard.
*/
- function __toString() {
+ public function __toString() {
return base64_encode($this->data());
}
@@ -501,7 +505,7 @@ class OC_Image implements \OCP\IImage {
*/
public function load($imageRef) {
if (is_resource($imageRef)) {
- if (get_resource_type($imageRef) == 'gd') {
+ if (get_resource_type($imageRef) === 'gd') {
$this->resource = $imageRef;
return $this->resource;
} elseif (in_array(get_resource_type($imageRef), array('file', 'stream'))) {