for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* This file is part of the Axstrad library.
*
* (c) Dan Kempster <[email protected]>
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
* @copyright 2014-2015 Dan Kempster <[email protected]>
*/
namespace Axstrad\Component\Content\Traits;
use Axstrad\Component\Content\Exception\InvalidArgumentException;
* Axstrad\Bundle\ContentBundle\Traits\Introduction
* Property requirements
* - $introduction = null
* @author Dan Kempster <[email protected]>
* @license MIT
* @package Axstrad/Content
* @since 0.3
trait Introduction
{
* Set introduction
* @param null|string $introduction
* @return self
public function setIntroduction($introduction = null)
if ($introduction === null) {
/** @noinspection PhpUndefinedFieldInspection */
$this->introduction = null;
introduction
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
class MyClass { } $x = new MyClass(); $x->foo = true;
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:
class MyClass { public $foo; } $x = new MyClass(); $x->foo = true;
}
elseif (!is_scalar($introduction)) {
throw InvalidArgumentException::create(
'null or string',
$introduction
);
else {
$this->introduction = (string) $introduction;
return $this;
* Get introduction
* @return null|string
public function getIntroduction()
return $this->introduction;
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: