PHP Classes
elePHPant
Icontem

PHP Morse Code: Encode or decode your Morse code messages

Recommend this page to a friend!
  Info   View files Documentation   View files View files (10)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2019-02-20 (1 month ago) RSS 2.0 feedNot yet rated by the usersTotal: 73 This week: 2All time: 9,330 This week: 242Up
Version License PHP version Categories
morsecode 1.0.0MIT/X Consortium ...5PHP 5, Text processing, Audio
Description Author

This class can encode or decode your Morse code messages.

It can take a text message and encode it using the Morse code by representing each short tone as a dot (.) and a long tone as a slash (/).

The class can also do the opposite, i.e. take a string previously encoded using the Morse code with this class and decode it to recover the original text message.

Innovation Award
PHP Programming Innovation award nominee
February 2019
Nominee
Vote
Morse code is a very old way that was used in the past to exchange messages using telegrams.

Morse code is still used nowadays to exchange messages via radio waves in the aviation and by amateur radio operators.

This class can encode and decode text messages using the Morse code.

Manuel Lemos
  Performance   Level  
Name: Johnny Mast <contact>
Classes: 9 packages by
Country: The Netherlands The Netherlands
Age: 36
All time rank: 158146 in The Netherlands The Netherlands
Week rank: 45 Up2 in The Netherlands The Netherlands Up
Innovation award
Innovation award
Nominee: 4x

Details

Build Status Scrutinizer Code Quality

Morsecode

This package allows you to encode or decode morsecode messages.

Encoding

If you wish to encode your message you can use the encode method.

use johnnymast\Morsecode\Morsecode;

$morse = new Morsecode();
echo $morse->encode('This is a test');

Decoding

If you wish to decode your message you can use the decode method.

use johnnymast\Morsecode\Morsecode;

$morse = new Morsecode();
echo $morse->decode('.... .. ... / .. ... / .- / - . ... -');

Alternative methods

You can also pass the message you wish you encode or decode via the constructor of the class like so.

use johnnymast\Morsecode\Morsecode;

$morse = new Morsecode('This is a test');
echo $morse->encode();

Return values

The encode and decode methods could return en empty string if no translation could beforce. So please take note of this.

Installation

Using composer:

$ composer require johnnymast/morsecode

Requirements

The following versions of PHP are supported by this version.

  • PHP 7.0
  • PHP 7.1
  • HHVM

Development Requirements

  • Phpunit 5.7

Author

This package is created and maintained by Johnny Mast. If you have any questions feel free to contact me on twitter by using @mastjohnny in your tweet.

License

Copyright (c) 2017 Johnny Mast

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

  Files folder image Files  
File Role Description
Files folder imagespec (1 file)
Files folder imagesrc (1 file)
Files folder imagetests (1 file)
Accessible without login Plain text file .php_cs Example Example script
Accessible without login Plain text file .scrutinizer.yml Data Auxiliary data
Accessible without login Plain text file .travis.yml Data Auxiliary data
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file phpspec.yml Data Auxiliary data
Accessible without login Plain text file phpunit.xml Data Auxiliary data
Accessible without login Plain text file README.md Doc. Documentation

  Files folder image Files  /  spec  
File Role Description
  Plain text file MorsecodeSpec.php Class Class source

  Files folder image Files  /  src  
File Role Description
  Plain text file Morsecode.php Class Class source

  Files folder image Files  /  tests  
File Role Description
  Plain text file MorsecodeTest.php Class Class source

 Version Control Unique User Downloads Download Rankings  
 100%
Total:73
This week:2
All time:9,330
This week:242Up