Introduction
Purpose: This challenge is part of your application process at SocyList. The focus is not only on task completion but also on how well you communicate your process and planning. So before you start, read all the steps carefully and answer the questions below for yourself:-
Pre-task Questions:
- 1. What is the (end) goal?
- 2. What do I already understand, and what needs further information?
- >>> Communicate your schedule before you actually start!
Required Software
List of Tools: Below are the tools needed to complete this challenge, along with links for official installation guides:
- 1. Command Line PHP (Version 7.4): Required for executing PHP scripts from the command line.
- 2. Composer – Dependency Manager for PHP: Used to manage project dependencies.
- 3. Visual Studio Code or another IDE: For code development.
Instructions
Setup Steps
- 1. Start a new Composer Library project: Follow these Composer setup instructions.
Required Steps
- 2. Create a String Shortening Method in PHP:
- a. Develop a method to shorten long strings by replacing the middle part with “…”.
- b. Example input/output:
"abcdefghijklmnopqrstuvwxyz"→"abc…xyz".
- 3. Add PHPUnit Unit Test for the Method:
- a. Write a unit test to validate the string-shortening method.
- b. Reference: PHPUnit Testing Guide
Optional Steps
Enhance the method by implementing alternative versions:-
- -> Implementation 0 – Original: Keep the initial method from Step 1.
- -> Implementation 1 – Minimalistic: Create the method with as few statements as possible.
- -> Implementation 2 – Robust: Ensure the method handles exceptions and errors smoothly.
- -> Implementation 3 – Generic: Make the method reusable in various scenarios.
Submission Steps
- -> Submit via WeTransfer: Deliver the complete project as a downloadable file on WeTransfer.
- -> Include all required files: Ensure the submission includes code, tests, and any relevant screenshots.
Good luck!
