Skip to content

GitLab

  • Menu
Projects Groups Snippets
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in
  • D digitec-wiki
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 0
    • Issues 0
    • List
    • Boards
    • Service Desk
    • Milestones
  • Deployments
    • Deployments
    • Releases
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Commits
  • Issue Boards
Collapse sidebar
  • Digitec
  • digitec-wiki
  • Wiki
  • php coding standards

php coding standards · Changes

Page history
mmclin: update naming conventions authored Mar 25, 2014 by Rene Cabral's avatar Rene Cabral
Show whitespace changes
Inline Side-by-side
php-coding-standards.markdown
View page @ 5361bd79
...@@ -25,12 +25,13 @@ Since a picture - or some code - is worth a thousand words, here's a short examp ...@@ -25,12 +25,13 @@ Since a picture - or some code - is worth a thousand words, here's a short examp
<?php <?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 * Author: rwilbert
* file that was distributed with this source code. *
* Date: mm/dd/yy
*/ */
namespace Acme; namespace Acme;
...@@ -41,13 +42,13 @@ namespace Acme; ...@@ -41,13 +42,13 @@ namespace Acme;
class FooBar { class FooBar {
const SOME_CONST = 42; const SOME_CONST = 42;
private $foo_bar; private $fooBar;
/** /**
* @param string $dummy Some argument description * @param string $dummy Some argument description
*/ */
public function __construct($dummy) { public function __construct($dummy) {
$this->foo_bar = $this->transformText($dummy); $this->fooBar = $this->transformText($dummy);
} }
/** /**
...@@ -55,14 +56,16 @@ class FooBar { ...@@ -55,14 +56,16 @@ class FooBar {
* @param array $options * @param array $options
* *
* @return string|null Transformed input * @return string|null Transformed input
*
* @throws \RuntimeException
*/ */
private function transformText($dummy, array $options = array()) { private function transformText($dummy, array $options = array()) {
$mergedOptions = array_merge( $mergedOptions = array_merge(
$options,
array( array(
'some_default' => 'values', 'some_default' => 'values',
'another_default' => 'more values', 'another_default' => 'more values',
) ),
$options
); );
if (true === $dummy) { if (true === $dummy) {
...@@ -70,19 +73,15 @@ class FooBar { ...@@ -70,19 +73,15 @@ class FooBar {
} }
if ('string' === $dummy) { if ('string' === $dummy) {
if ('values' === $mergedOptions['some_default']) { if ('values' === $mergedOptions['some_default']) {
$dummy = substr($dummy, 0, 5); return substr($dummy, 0, 5);
} else {
$dummy = ucwords($dummy);
}
} 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 ### Structure
......
Clone repository
  • alpha beta testing
  • browser testing
  • camtasia licenses
  • code delivery processes
  • coding practices
  • css and sass coding standards
  • database schema standards
  • dependency management
  • development environments
  • digitec agile process
  • digitec gitlab styles
  • digitec software promises
  • digitec spec process
  • gitlab administration
  • gitlab issues tags
View All Pages