-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Ramazan Çetinkaya
authored
Jan 6, 2024
1 parent
86c08da
commit 4baf78c
Showing
1 changed file
with
39 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,40 @@ | ||
# morse-code | ||
# Morse Code | ||
|
||
A simple PHP library for converting text to Morse code and vice versa | ||
|
||
## Installation | ||
|
||
This library can be easily installed using [Composer](https://getcomposer.org/), a modern PHP dependency manager. | ||
|
||
### Step 1: Install Composer | ||
|
||
If you don't have Composer installed, you can download and install it by following the instructions on the [official Composer website](https://getcomposer.org/download/). | ||
|
||
### Step 2: Install the Library | ||
|
||
Once Composer is installed, you can install the `morse-code` library by running the following command in your project's root directory: | ||
|
||
```bash | ||
composer require ramazancetinkaya/morse-code | ||
``` | ||
|
||
## Usage | ||
|
||
```php | ||
require_once 'vendor/autoload.php'; // Include Composer's autoloader | ||
|
||
use ramazancetinkaya\MorseCode; | ||
``` | ||
|
||
```php | ||
try { | ||
$text = "Hello World"; | ||
$morse = MorseCode::textToMorse($text); | ||
echo "Text to Morse: " . $morse . "\n"; | ||
|
||
$originalText = MorseCode::morseToText($morse); | ||
echo "Morse to Text: " . $originalText . "\n"; | ||
} catch (InvalidArgumentException $e) { | ||
echo "Error: " . $e->getMessage() . "\n"; | ||
} | ||
``` |