Code Monkey home page Code Monkey logo

scnip-assessment's Introduction

Scnip Backend Developer Assessment

This repository contains the solutions to scnip backend developer assessment role.

Getting Started

This guide assumed you have PHP 8.2+ and Composer installed on your pc.

Clone and Navigate

Clone this repository and navigate into it:

git clone https://github.com/iamolayemi/scnip-assessment.git 

cd scnip-assessment

Install Dependencies

composer install

Running the Example Script.

To run the example script:

php main.php

This should display a formatted output similar to the one below in the console.

Products Without Sorting
+----+-----------------+-------+-------------+-------------+------------+
| ID | Name            | Price | Sales Count | Views Count | Created At |
+----+-----------------+-------+-------------+-------------+------------+
| 1  | Alabaster Table | 12.99 | 32          | 730         | 2019-01-04 |
| 2  | Zebra Table     | 44.49 | 301         | 3279        | 2012-01-04 |
| 3  | Coffee Table    | 10    | 1048        | 20123       | 2014-05-28 |
+----+-----------------+-------+-------------+-------------+------------+

Products Sorted By Price
+----+-----------------+-------+-------------+-------------+------------+
| ID | Name            | Price | Sales Count | Views Count | Created At |
+----+-----------------+-------+-------------+-------------+------------+
| 3  | Coffee Table    | 10    | 1048        | 20123       | 2014-05-28 |
| 1  | Alabaster Table | 12.99 | 32          | 730         | 2019-01-04 |
| 2  | Zebra Table     | 44.49 | 301         | 3279        | 2012-01-04 |
+----+-----------------+-------+-------------+-------------+------------+

Products Sorted By Sales Per View
+----+-----------------+-------+-------------+-------------+------------+
| ID | Name            | Price | Sales Count | Views Count | Created At |
+----+-----------------+-------+-------------+-------------+------------+
| 1  | Alabaster Table | 12.99 | 32          | 730         | 2019-01-04 |
| 3  | Coffee Table    | 10    | 1048        | 20123       | 2014-05-28 |
| 2  | Zebra Table     | 44.49 | 301         | 3279        | 2012-01-04 |
+----+-----------------+-------+-------------+-------------+------------+

You can open and edit the main.php file with your preferred IDE or code editor to experiment with different sorting scenarios.

Adding a New Sorter

To add a new sorter, follow these steps:

  1. Create a new class in the src/Sorters folder that implements the ProductSorter interface.
  2. Implement the sort method in the new sorter class.

Testing

To run unit tests, execute the following command:

composer test

scnip-assessment's People

Contributors

iamolayemi avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.