1*0b3fd2d3SAndreas Gohr<?php 2*0b3fd2d3SAndreas Gohr 3*0b3fd2d3SAndreas Gohr/** 4*0b3fd2d3SAndreas Gohr * This file is part of the FreeDSx SASL package. 5*0b3fd2d3SAndreas Gohr * 6*0b3fd2d3SAndreas Gohr * (c) Chad Sikorra <Chad.Sikorra@gmail.com> 7*0b3fd2d3SAndreas Gohr * 8*0b3fd2d3SAndreas Gohr * For the full copyright and license information, please view the LICENSE 9*0b3fd2d3SAndreas Gohr * file that was distributed with this source code. 10*0b3fd2d3SAndreas Gohr */ 11*0b3fd2d3SAndreas Gohr 12*0b3fd2d3SAndreas Gohrnamespace FreeDSx\Sasl\Encoder; 13*0b3fd2d3SAndreas Gohr 14*0b3fd2d3SAndreas Gohruse FreeDSx\Sasl\Message; 15*0b3fd2d3SAndreas Gohruse FreeDSx\Sasl\SaslContext; 16*0b3fd2d3SAndreas Gohr 17*0b3fd2d3SAndreas Gohr/** 18*0b3fd2d3SAndreas Gohr * Responsible for encoding / decoding ANONYMOUS messages. 19*0b3fd2d3SAndreas Gohr * 20*0b3fd2d3SAndreas Gohr * @author Chad Sikorra <Chad.Sikorra@gmail.com> 21*0b3fd2d3SAndreas Gohr */ 22*0b3fd2d3SAndreas Gohrclass AnonymousEncoder implements EncoderInterface 23*0b3fd2d3SAndreas Gohr{ 24*0b3fd2d3SAndreas Gohr /** 25*0b3fd2d3SAndreas Gohr * {@inheritDoc} 26*0b3fd2d3SAndreas Gohr */ 27*0b3fd2d3SAndreas Gohr public function encode(Message $message, SaslContext $context): string 28*0b3fd2d3SAndreas Gohr { 29*0b3fd2d3SAndreas Gohr if ($message->has('trace')) { 30*0b3fd2d3SAndreas Gohr return $message->get('trace'); 31*0b3fd2d3SAndreas Gohr } 32*0b3fd2d3SAndreas Gohr 33*0b3fd2d3SAndreas Gohr return ''; 34*0b3fd2d3SAndreas Gohr } 35*0b3fd2d3SAndreas Gohr 36*0b3fd2d3SAndreas Gohr /** 37*0b3fd2d3SAndreas Gohr * {@inheritDoc} 38*0b3fd2d3SAndreas Gohr */ 39*0b3fd2d3SAndreas Gohr public function decode(string $data, SaslContext $context): Message 40*0b3fd2d3SAndreas Gohr { 41*0b3fd2d3SAndreas Gohr $message = new Message(); 42*0b3fd2d3SAndreas Gohr 43*0b3fd2d3SAndreas Gohr if($data !== '') { 44*0b3fd2d3SAndreas Gohr $message->set('trace', $data); 45*0b3fd2d3SAndreas Gohr } 46*0b3fd2d3SAndreas Gohr 47*0b3fd2d3SAndreas Gohr return $message; 48*0b3fd2d3SAndreas Gohr } 49*0b3fd2d3SAndreas Gohr} 50