Tagged Questions
0
votes
0answers
25 views
Is there a better way to cache a static property in PHP? [on hold]
I have an arbitrary number of classes already extending a base class, and I'd like for each of these extending classes to have a static function with the same name. This function is often very ...
4
votes
2answers
55 views
Finite Element Method analysis
Please take a look at this class and point out its flaws. I am developing a simple Finite Element Method analysis with PHP.
What this class basically does:
Given an input set (coordinates, ...
1
vote
1answer
45 views
Better PHP Autentication Class [closed]
Authentication and keeping information secure is my goal with writing my Authentication class while making sure it is extendable completely as possible over making it usable for anything over just ...
3
votes
2answers
141 views
Updating necessary data using just one function
My objective is to update necessary data using one function instead of having different functions to update different fields. So, I've created one and I think this is not really elegant, efficient or ...
0
votes
0answers
16 views
Re-factoring restrictions validation functions for proper OOP design in MVC framework
I am aware that code review is for refactoring code from an existing code. Let me first to say that the following code works but inefficiently and its very convoluted, so I would like to apologize if ...
2
votes
2answers
75 views
Validator extended to handle domain objects / entities
I started improving my validator library even more, and I think I'm at the last final element (domain object / entity validations) before I can gladly say that my Validator library is completely done ...
3
votes
1answer
68 views
My first login class in PHP with PDO and bcrypt
This is the first time using a class. Please review this and tell me if it's secure and if it's the right way to do it. The code itself is working, but I have doubts in the way I used all this.
...
5
votes
2answers
80 views
Update of Classes for user registration and authentication
Old Post: Classes for user registration and authentication
This post is an update of the old post of mine. This is the code after suggestions were implemented in the review. Do you think I could make ...
0
votes
2answers
36 views
5
votes
1answer
85 views
4
votes
2answers
90 views
Validator refactored to be OO
Based on my previous post I completely re-factored my code to make it object oriented.
Anything I could improve when it comes to:
Object oriented code;
Efficiency;
Readability.
Any other ...
5
votes
1answer
39 views
Secure Functions in a Database Class
I am trying to solve as many issues as possible with my Database Class and bind statements as far as possible without actually doing it in the front-end. The goal is to do all of the heaving lifting ...
3
votes
2answers
75 views
Getting cars and bicycles from a database and writing them into two different arrays
I've written a simple class which should:
get 10 top cars and 10 top bicycles from database
write them into 2 different arrays
It works, but I'm trying to find a simpler or clearer solution.
...
0
votes
1answer
41 views
PHP ImageMagick Image Processing Class
I've written an image processing library for downscaling, sharpening, compressing and caching images using PHP and ImageMagick.
Having recently been a chef in the kitchen of procedural and vague ...
5
votes
1answer
59 views
Social application with users and sessions
I work with a legacy application. This is my attempt to add some sanity in an new feature I want to add.
It's a social application with users, sessions etc. The entire application is run in a ...
0
votes
1answer
63 views
Is this the right way to write OOP PDO classes? [closed]
I have just begun to work with OOP and I am converting my current project into OOP classes. I have a few questions about this User class.
...
5
votes
2answers
101 views
Converting bootstrap file from procedural code to OOP
My bootstrap file contained procedural code, but after stumbling upon this answer I tried to make my bootstrap object oriented.
This is my attempt so far, and I have a feeling that I'm failing at it. ...
5
votes
1answer
72 views
OOP Decision Maker Class - ServerArbiter
I am writing a ServerArbiter, the job of which is to make a decision about which server to "choose" given a set of rules. The aim is to be able to add / remove ...
3
votes
1answer
81 views
Validator Readability and Efficiency
This is my first validator I have created myself and I was wondering if there is anything about it that I could improve as far as:
Code readability
Code efficiency
Note: The reason why I put an ...
4
votes
1answer
91 views
My simple PDO wrapper class
I made a simple database class and I wanted to know if there are any improvements I could work on as far as readability, efficiency, methods and making it modular goes.
Any other suggestions are also ...
5
votes
1answer
107 views
PHP library for handling account creations, logins, and file uploads
I'm new to OOP and PHP. I've made an attempt at a PHP library file that handles account creations, logins, and file uploads with image resizing on the fly. It works so far. I'd like some help with ...
2
votes
2answers
75 views
0
votes
1answer
69 views
How to write this code more efficient and simplify creation of dependency objects?
How can I write my code more efficient (not repeating same code)?
And is there a solution that simplifies the way of having to create a lot of dependency objects over and over again whenever I ...
-2
votes
1answer
51 views
Is the this the correct way of using OOP for a student class?
I tried use use HTML tags as my own way in PHP using objects.
Is this the correct method of writing or implementing OOP? If not, what is the best way to write such type of code?
...
1
vote
1answer
60 views
How to re-factor dynamic menu code to OOP in a MVC framework?
I have a MVC framework, and I am struggling with the following dynamic menu code.
A menu is pretty much HTML, so technically it should reside in the View, but the dynamic part is driven by PHP and a ...
2
votes
1answer
61 views
Calling one method both dynamically and statically
I'm currently working on a PHP component: "Filesystem handler". I've run into a problem where I want to call one exact method in both dynamic and static ways.
I've ended up with this solution. Could ...
0
votes
1answer
99 views
2
votes
1answer
79 views
Is my Controller class functionality correct?
I'm building my own micro MVC framework with only the absolute core functionality.
How my controller works is that my router will call the controller depending on the request method (GET or POST). ...
2
votes
1answer
51 views
What is an proper way of routing to the right controller in MVC patterns?
I always been curious on how to build great application with proper routing to my controllers, but after seeing some sources of applications like Xenforo, Joomla, it seems completely different, and ...
1
vote
1answer
64 views
RequestHandler: Is my code clean?
I've built a simple class RequestHandler that does exactly what I want without any extras I won't be utilizing. When needed I will expand. I'm passing this object ...
2
votes
1answer
145 views
Router for MVC framework: Is it OO and good to go?
Am I utilizing dependency injection correctly?
Any parts of my class that I should decouple?
Anything I could improve in my code when it comes to OO PHP (and MVC)?
The class routes URLs based on ...
0
votes
1answer
104 views
Is my first MVC architecture set up to standards?
I just started learning about the MVC architecture. And I started to create my own MVC framework to how I like it the most.
Here I've got the index.php, indexcontroller.php and view.php. I'm not too ...
1
vote
3answers
115 views
Does my input helper class look good?
I'm new to OOP PHP and I created a simple input helper class. And was wondering if it's good? Are my dependencies good?
Also the reason I'm not throwing an exception with the get method is that I ...
3
votes
2answers
68 views
Is this following Separation of Concerns and PHP OOP standards?
I've been working with PHP for a while now, but unfortunately haven't delved into the OO side of it until recently. I've been reading up on separation of concerns and OOP best practices, and I think ...
1
vote
2answers
129 views
Creating a Party Game to learn OOP
I've been developing sites using Dreamweaver for the last 15 years, I do a lot of code editing manually so I have quite a good knowledge of the PHP language.
I'm diving into object orientated ...
5
votes
2answers
73 views
Avoiding globals in gumball machine class
I'm planning to transition from years of forced procedural programming to OOP. I decided I'd start off small with a little gumball machine object to get my bearings. Everything seems to run ok, but I ...
5
votes
2answers
125 views
UK tax calculator
I'm very much on the beginner end of the PHP scale but I have read plenty of the entry level books and completed the online training at teamtreehouse.com so I know the basics.
I'm at a point where ...
4
votes
1answer
107 views
Throw exception in favor of an error?
I've been reviewing my previous projects for the last few days. I've found that I never return an error from any of my methods. I always throw exceptions. I googled about exceptions vs errors and I ...
1
vote
1answer
53 views
Class that handles header and footer includes looks like a mess
I tried making a class that handles my header and footer of my site. It looks like a mess, because I like to preserve the indentations as is.
But I'm wondering if there maybe is an even cleaner or ...
4
votes
2answers
72 views
Reduce similar methods via pattern?
I've put together a simple application in order for me to learn sqlite and OOP in PHP. The application basically outputs two random words, e.g. "Angry Badger", from two database tables, one called ...
3
votes
1answer
73 views
Redunancy Issues in PHP Class
I've been studying PHP for a while now and decided to dive into OOP. Most of my code was a mess and I've begun to refactor much of the website to OOP; however, I'm having an issue with redundancy in ...
7
votes
1answer
67 views
Making a FileHandler more OOP friendly using SOLID
I have a class created for the sole purpose is to help handle files.
The class holds a path(folder) that contains a single file at a time. Some extra properties to this class are: age of a file and ...
5
votes
4answers
180 views
Neatest way of including a header and footer on every page
I just got into Object Oriented Programming, and it made me think about certain code how I can make them as efficient as possible.
Right now I am just including my header and footer like the ...
1
vote
1answer
78 views
Is this way of passing a parameter relatively safe? [closed]
I'm still playing with how I want to build the parameter. However, in the end I still want to pass it to the prepare statement the same. Note: $this->dbh is ...
6
votes
1answer
138 views
My first project using namespaces
I have to create some APIs for a online game and I decided to learn to use namespaces correctly.
I used the factory pattern, then the loadModule method checks if ...
4
votes
2answers
149 views
OOP Simple Contact Form
Here is my Code. But I feel that my code isn't really that much object oriented.
There is a small piece of "styling" in it aswell, the "message error" thing at the end.
Should that be in my class ...
5
votes
1answer
346 views
How is OOP achieved with configuration files in PHP?
Someone asked if their singleton is good for OOP:
Using a singleton class to get and set program wide settings.
However, the answer just provides tweaks to his existing code - but the question ...
3
votes
1answer
105 views
How to go from Spaghetti PHP OOP to SOLID OOP?
I am beyond stuck in a half way point between PHP structural and OOP, but I can never achieve proper SOLID patterns despite reading DI, IOC, and reading about the interfaces.
Rather than to read ...
0
votes
1answer
36 views
Using one parent model and other extending it in PHP framework
I have multiple models which all have the same functions in it in my framework. So I decided to create one "parent" model and all of my other models would extend and inherit its functions like:
...
3
votes
1answer
145 views
Simple application to experience encapsulation
Looking at the code, is this a proper example of encapsulation?
additionalComputer.php (class)
...