for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare(strict_types=1);
namespace Hyphper\Frame;
trait PaddingTrait
{
protected $padding_length;
public function __construct(array $options = [])
parent::__construct($options);
$this->padding_length = (int) ($options['padding_length'] ?? 0);
}
/**
* @param int $padding_length
*/
public function setPaddingLength(int $padding_length)
$this->padding_length = $padding_length;
* @return int
public function getPaddingLength()
return $this->padding_length;
* @return string
protected function serializePaddingData(): string
if ($this->flags->hasFlag(Flag::PADDED)) {
flags
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;
return pack('C', $this->padding_length);
return '';
* @param string $data
*
* @throws Exception\InvalidFrameException
protected function parsePaddingData(string $data): int
if (!$unpack = @unpack('Cpadding_length', substr($data, 0, 1))) {
throw new \Hyphper\Frame\Exception\InvalidFrameException("Invalid Padding Data");
$this->padding_length = $unpack['padding_length'];
return static::IS_PADDED;
return static::IS_NOT_PADDED;
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: