-
-
Save apueee/5886197 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
* This file is a demonestration for PHP Coding Standareds of WNeeds Ltd. | |
* | |
* (c) WNeeds Ltd. <anis@wneeds.com> | |
*/ | |
namespace Wneeds; | |
/** | |
* Coding standards demonstration. | |
*/ | |
class Editor | |
{ | |
const LE_UNIX = 'unix'; | |
const LE_WIN = 'windows'; | |
private $_sourceCode; | |
/** | |
* @var \Wneeds\One\Another | |
*/ | |
protected $_anotherVar; | |
/** | |
* @param string $_sourceCode Some argument description | |
*/ | |
public function __construct($sourceCodeFile) | |
{ | |
$this->_sourceCode = $this->_readContent($sourceCodeFile); | |
} | |
/** | |
* @param string $sourceCodeFile Some argument description | |
* @param array $options List of allowed options | |
* | |
* @return string|null Transformed source code file | |
*/ | |
private function _readContent($sourceCodeFile, $options = array()) | |
{ | |
$mergedOptions = array_merge( | |
$options, | |
array( | |
'language' => 'php', | |
'file_ending' => $this::LE_UNIX, | |
) | |
); | |
if (true === $this::LE_UNIX) { | |
// So something to read file | |
} | |
// Not real, just to show convensions | |
if ('string' == $sourceCodeFile) { | |
if ('values' == $mergedOptions['some_default']) { | |
$sourceCodeFile = substr($sourceCodeFile, 0, 5); | |
} else { | |
$sourceCodeFile = ucwords($sourceCodeFile); | |
} | |
} else { | |
throw new \RuntimeException(sprintf('Unrecognized $sourceCodeFile option "%s"', $sourceCodeFile)); | |
} | |
return $sourceCodeFile; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment