... | ... | @@ -25,12 +25,13 @@ Since a picture - or some code - is worth a thousand words, here's a short examp |
|
|
<?php
|
|
|
|
|
|
/*
|
|
|
* This file is part of the KD package.
|
|
|
* This file is part of the kd.batman project.
|
|
|
*
|
|
|
* (c) Digitec Interactive
|
|
|
* (c) Digitec Interactive 2014. All rights reserved.
|
|
|
*
|
|
|
* For the full copyright and license information, please view the LICENSE
|
|
|
* file that was distributed with this source code.
|
|
|
* Author: rwilbert
|
|
|
*
|
|
|
* Date: mm/dd/yy
|
|
|
*/
|
|
|
|
|
|
namespace Acme;
|
... | ... | @@ -41,13 +42,13 @@ namespace Acme; |
|
|
class FooBar {
|
|
|
const SOME_CONST = 42;
|
|
|
|
|
|
private $foo_bar;
|
|
|
private $fooBar;
|
|
|
|
|
|
/**
|
|
|
* @param string $dummy Some argument description
|
|
|
*/
|
|
|
public function __construct($dummy) {
|
|
|
$this->foo_bar = $this->transformText($dummy);
|
|
|
$this->fooBar = $this->transformText($dummy);
|
|
|
}
|
|
|
|
|
|
/**
|
... | ... | @@ -55,14 +56,16 @@ class FooBar { |
|
|
* @param array $options
|
|
|
*
|
|
|
* @return string|null Transformed input
|
|
|
*
|
|
|
* @throws \RuntimeException
|
|
|
*/
|
|
|
private function transformText($dummy, array $options = array()) {
|
|
|
$mergedOptions = array_merge(
|
|
|
$options,
|
|
|
array(
|
|
|
'some_default' => 'values',
|
|
|
'another_default' => 'more values',
|
|
|
)
|
|
|
),
|
|
|
$options
|
|
|
);
|
|
|
|
|
|
if (true === $dummy) {
|
... | ... | @@ -70,19 +73,15 @@ class FooBar { |
|
|
}
|
|
|
if ('string' === $dummy) {
|
|
|
if ('values' === $mergedOptions['some_default']) {
|
|
|
$dummy = substr($dummy, 0, 5);
|
|
|
} else {
|
|
|
$dummy = ucwords($dummy);
|
|
|
return substr($dummy, 0, 5);
|
|
|
}
|
|
|
} else {
|
|
|
throw new \RuntimeException(sprintf('Unrecognized dummy option "%s"', $dummy));
|
|
|
}
|
|
|
|
|
|
return $dummy;
|
|
|
return ucwords($dummy);
|
|
|
}
|
|
|
throw new \RuntimeException(sprintf('Unrecognized dummy option "%s"', $dummy));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
|
### Structure
|
... | ... | |