Demo entry 2702407

adsfa

   

Submitted by anonymous on Sep 18, 2015 at 09:22
Language: PHP. Code size: 811 Bytes.

<?php

// Open/Closed Principle 
// Falsch
class Picture
{
	private $file_name;

	public function __construct($file_name)
	{
		$this->file_name = $file_name;
	}
	public function getFullFilePath()
	{
		$filepath = '/htdocs/pictures/'.$this->$file_name;
		return $filepath;
	}
	public function getFileExtension()
	{
		$filepath = $this->getFullFilePath();
		$file_name = basename($filepath);
		$extension = array_pop(explore(".", $file_name));
		return $extension;
	}
	public function getNoticeOfPictureType() 
	{
		$extension = $this->getFileExtension();

		switch ($extension)
		{
			case 'jpeg':
			$notice = 'Joint Photographic Experts Group';
			return $notice;
			break;

			case 'png':
			$notice = 'Portable Network Graphics';
			return $notice;
			break;
		}
	}
}

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).