for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare(strict_types=1);
namespace Psi\Bridge\ContentType\Doctrine\PhpcrOdm;
/**
* Responsible for encoding PHPCR property names which are managed by the
* content-type component.
*/
class PropertyEncoder
{
public function __construct(string $prefix, string $uri)
$this->prefix = $prefix;
prefix
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;
$this->uri = $uri;
uri
}
* Encode a field name. If the field reprents a compound type then $key
* should be passed to represent the key for the value of the compound
* field.
public function encode(string $fieldName, string $key = null): string
$propertyName = sprintf(
'%s:%s',
$this->prefix,
$fieldName
);
if (null !== $key) {
$propertyName .= '-' . $key;
return $propertyName;
* Return the PHPCR namespace prefix (alias).
public function getPrefix(): string
return $this->prefix;
* Return the namespace URI.
public function getUri(): string
return $this->uri;
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: